Mercurial > hg > Database > Christie-sharp
changeset 1:740b80680d75
add Codegear and Datagear files
author | riono <e165729@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 21 Jun 2020 01:48:25 +0900 (2020-06-20) |
parents | e858d217d464 |
children | 839e355f92ed |
files | Program.cs annotation/Peek.cs annotation/PeekFrom.cs annotation/Take.cs annotation/TakeFrom.cs codegear/CodeGear.cs codegear/InputDataGear.cs datagear/WrapperClass.cs datagear/dg/DataGear.cs |
diffstat | 9 files changed, 119 insertions(+), 37 deletions(-) [+] |
line wrap: on
line diff
--- a/Program.cs Thu Jun 11 22:57:34 2020 +0900 +++ b/Program.cs Sun Jun 21 01:48:25 2020 +0900 @@ -1,23 +1,15 @@ using System; +using System.Threading; using Christie_net.annotation; -namespace Christie_net -{ - class Program - { - [Peek] - Test testindex; - - static void Main(string[] args) - { +namespace Christie_net { + class Program { + //[Peek] Test testindex; + + static void Main(string[] args) { Console.WriteLine("Hello World!"); - + } } - class Test - { - public int index; - public String text; - } } \ No newline at end of file
--- a/annotation/Peek.cs Thu Jun 11 22:57:34 2020 +0900 +++ b/annotation/Peek.cs Sun Jun 21 01:48:25 2020 +0900 @@ -1,9 +1,7 @@ using System; -namespace Christie_net.annotation -{ +namespace Christie_net.annotation { [AttributeUsage(AttributeTargets.Field)] - public class Peek : Attribute - { + public class Peek : Attribute { } } \ No newline at end of file
--- a/annotation/PeekFrom.cs Thu Jun 11 22:57:34 2020 +0900 +++ b/annotation/PeekFrom.cs Sun Jun 21 01:48:25 2020 +0900 @@ -1,14 +1,11 @@ using System; -namespace Christie_net.annotation -{ +namespace Christie_net.annotation { [AttributeUsage(AttributeTargets.Field)] - public class PeekFrom : Attribute - { + public class PeekFrom : Attribute { private string _name; - - public String value() - { + + public String value() { return _name; } }
--- a/annotation/Take.cs Thu Jun 11 22:57:34 2020 +0900 +++ b/annotation/Take.cs Sun Jun 21 01:48:25 2020 +0900 @@ -1,10 +1,8 @@ using System; -namespace Christie_net.annotation -{ +namespace Christie_net.annotation { [AttributeUsage(AttributeTargets.Field)] - public class Take : Attribute - { - + public class Take : Attribute { + } } \ No newline at end of file
--- a/annotation/TakeFrom.cs Thu Jun 11 22:57:34 2020 +0900 +++ b/annotation/TakeFrom.cs Sun Jun 21 01:48:25 2020 +0900 @@ -1,14 +1,11 @@ using System; -namespace Christie_net.annotation -{ +namespace Christie_net.annotation { [AttributeUsage(AttributeTargets.Field)] - public class TakeFrom : Attribute - { + public class TakeFrom : Attribute { private string _name; - public String value() - { + public String value() { return _name; } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/codegear/CodeGear.cs Sun Jun 21 01:48:25 2020 +0900 @@ -0,0 +1,5 @@ +namespace Christie_net.codegear { + public abstract class CodeGear { + private InputDataGear idg; + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/codegear/InputDataGear.cs Sun Jun 21 01:48:25 2020 +0900 @@ -0,0 +1,32 @@ +using System.Collections.Concurrent; +using System.Collections.Generic; + +namespace Christie_net.codegear { + public class InputDataGear { + public ConcurrentDictionary<string, DataGear> inputValue = new ConcurrentDictionary<string, DataGear>(); + public CodeGearManager cgm; + public CodeGear cg; + private int count = 0; + + public InputDataGear(CodeGear cg) { + this.cg = cg; + } + + private void FinishInput(CodeGearManager cgm, List<Command> commandList) { + this.cgm = cgm; + count = commandList.Count; + + if (count == 0) { + SubmitCG(); + } + + foreach (Command cm in commandList) { + cgm.GetDGM(cm.toDgmName).RunCommand(cm); + } + } + + public void SetInputs(string key, DataGear dg) { + inputValue.AddOrUpdate(key, dg); + } + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/datagear/WrapperClass.cs Sun Jun 21 01:48:25 2020 +0900 @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; + +namespace Christie_net.datagear { + public class WrapperClass { + // public static Type wGetWrapperClass<T> (Type c) { + // return c.IsPrimitive ? + // } + + //public static const Dictionary<Type, Type> map = new Dictionary<Type, Type>(); + + + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/datagear/dg/DataGear.cs Sun Jun 21 01:48:25 2020 +0900 @@ -0,0 +1,49 @@ +using System; + +namespace Christie_net.datagear.dg { + public class DataGear<T> { + protected T data = default(T); + protected Type clazz = null; + + public DataGear(T data) { + SetClazz(data.GetType()); + SetData(data); + } + + public DataGear(Type clazz) { + SetClazz(clazz); + } + + public void SetData(T data) { + Type dataClazz = data.GetType(); + + if (dataClazz == this.clazz) { + this.data = data; + return; + } + + Type dataSuperClazz = dataClazz.BaseType; + while (dataSuperClazz != null) { + if (dataClazz == this.clazz) { + this.data = data; + return; + } + dataSuperClazz = dataSuperClazz.BaseType; + } + + Type[] interfaces = dataClazz.GetInterfaces(); + foreach (Type interfaze in interfaces) { + if (interfaze == this.clazz) { + this.data = data; + return; + } + } + + throw new InvalidCastException("datagear cannot set class from" + dataClazz.GetType().Name + " to " + data.GetType().Name); + } + + public void SetClazz(Type clazz) { + this.clazz = clazz; + } + } +} \ No newline at end of file