Example #1
0
 public CommandGeneratorH(NetworkCommand nc)
 {
     if (string.IsNullOrEmpty(nc.ClassName))
     {
         throw new ArgumentException("Required field cannot be null or empty.", "ClassName");
     }
     if (string.IsNullOrEmpty(nc.Name))
     {
         throw new ArgumentException("Required field cannot be null or empty.", "Name");
     }
     if (nc.Code < 0 | nc.Code > 0xFFFF)
     {
         throw new ArgumentOutOfRangeException("Code", "Your code number cannot be less than 0 or greater than 65,535.");
     }
     Namespace       = nc.Namespace ?? "Agent";
     ClassName       = nc.ClassName;
     Name            = nc.Name;
     Code            = nc.Code;
     Description     = nc.Description ?? "No Description Given";
     CommandType     = nc.CommandType ?? typeof(string);
     ClassProperties = nc.ClassProperties ?? new ObservableCollection <ClassProperty>();         // If they are blank we need to continue
     EnumerationList = nc.EnumerationList ?? new ObservableCollection <EnumerationDefinition>(); // If they are blank we need to continue
     TypeMapping     = new Dictionary <string, string>();
     foreach (var item in nc.TypeMapping)
     {
         TypeMapping.Add(item.OriginalType, item.NewType);
     }
 }
Example #2
0
 public CommandGeneratorCS(NetworkCommand nc)
 {
     if (string.IsNullOrEmpty(nc.ClassName))
         throw new ArgumentException("Required field cannot be null or empty.", "ClassName");
     if (string.IsNullOrEmpty(nc.Name))
         throw new ArgumentException("Required field cannot be null or empty.", "Name");
     if (nc.Code < 0 | nc.Code > 0xFFFF)
         throw new ArgumentOutOfRangeException("Code", "Your code number cannot be less than 0 or greater than 65,535.");
     Namespace = nc.Namespace ?? "Agent";
     ClassName = nc.ClassName;
     Name = nc.Name;
     Code = nc.Code;
     Description = nc.Description ?? "No Description Given";
     CommandType = nc.CommandType ?? typeof(string);
     ClassProperties = nc.ClassProperties ?? new ObservableCollection<ClassProperty>(); // If they are blank we need to continue
     EnumerationList = nc.EnumerationList ?? new ObservableCollection<EnumerationDefinition>(); // If they are blank we need to continue
     TypeMapping = new Dictionary<string, string>();
     foreach (var item in nc.TypeMapping)
     {
         TypeMapping.Add(item.OriginalType, item.NewType);
     }
 }
Example #3
0
        private void CreateDummyCommands()
        {
            var nc = new NetworkCommand();
            nc.Code = 0xff;
            nc.Name = "TestCommand";
            nc.Namespace = "Agent";
            nc.Description = "Test command long decription name";
            nc.ClassName = "TestCommandClass";
            nc.ClassProperties = new ObservableCollection<ClassProperty>();
            nc.ClassProperties.Add(new ClassProperty() { Name = "typ1", TypeName = typeof(string).FullName });
            nc.ClassProperties.Add(new ClassProperty() { Name = "typ2", TypeName = typeof(string).FullName });
            nc.EnumerationList = new ObservableCollection<EnumerationDefinition>();
            nc.EnumerationList.Add(new EnumerationDefinition());
            nc.EnumerationList.Last().Flags = true;
            nc.EnumerationList.Last().EnumerationName = "TestEnum";
            nc.EnumerationList.Last().Items = new ObservableCollection<EnumerationItem>();
            nc.EnumerationList.Last().Items.Add(new EnumerationItem() { Name = "BIG_ENUM_NAME", Value = 1 });
            nc.EnumerationList.Last().Items.Add(new EnumerationItem() { Name = "BIG_ENUM_NAME1", Value = 2 });
            nc.EnumerationList.Last().Items.Add(new EnumerationItem() { Name = "BIG_ENUM_NAME2", Value = 4 });
            nc.EnumerationList.Last().Items.Add(new EnumerationItem() { Name = "BIG_ENUM_NAME3", Value = 8 });

            nc.EnumerationList.Add(new EnumerationDefinition());
            nc.EnumerationList.Last().EnumerationName = "TestEnum 2";
            nc.EnumerationList.Last().Items = new ObservableCollection<EnumerationItem>();
            nc.EnumerationList.Last().Items.Add(new EnumerationItem() { Name = "BIG_ENUM_NAME", Value = 1 });
            nc.EnumerationList.Last().Items.Add(new EnumerationItem() { Name = "BIG_ENUM_NAME3", Value = 8 });

            var netcmd = CommandVM.NetworkCommands;
            netcmd.Add(new NetworkCommandTreeItemModel() { CommandName = nc.Name, NetworkCommand = nc });
            netcmd.Add(new NetworkCommandTreeItemModel() { CommandName = nc.Name, NetworkCommand = nc });
            netcmd.Add(new NetworkCommandTreeItemModel() { CommandName = nc.Name, NetworkCommand = nc });
            netcmd.Add(new NetworkCommandTreeItemModel() { CommandName = nc.Name, NetworkCommand = nc });
            netcmd.Add(new NetworkCommandTreeItemModel() { CommandName = nc.Name, NetworkCommand = nc });
            netcmd.Add(new NetworkCommandTreeItemModel() { CommandName = nc.Name, NetworkCommand = nc });
            netcmd.Add(new NetworkCommandTreeItemModel() { CommandName = nc.Name, NetworkCommand = nc });
            netcmd.Add(new NetworkCommandTreeItemModel() { CommandName = nc.Name, NetworkCommand = nc });

            var json = Newtonsoft.Json.JsonConvert.SerializeObject(CommandVM, Newtonsoft.Json.Formatting.Indented);
        }
Example #4
0
        private void CreateDummyCommands()
        {
            var nc = new NetworkCommand();

            nc.Code            = 0xff;
            nc.Name            = "TestCommand";
            nc.Namespace       = "Agent";
            nc.Description     = "Test command long decription name";
            nc.ClassName       = "TestCommandClass";
            nc.ClassProperties = new ObservableCollection <ClassProperty>();
            nc.ClassProperties.Add(new ClassProperty()
            {
                Name = "typ1", TypeName = typeof(string).FullName
            });
            nc.ClassProperties.Add(new ClassProperty()
            {
                Name = "typ2", TypeName = typeof(string).FullName
            });
            nc.EnumerationList = new ObservableCollection <EnumerationDefinition>();
            nc.EnumerationList.Add(new EnumerationDefinition());
            nc.EnumerationList.Last().Flags           = true;
            nc.EnumerationList.Last().EnumerationName = "TestEnum";
            nc.EnumerationList.Last().Items           = new ObservableCollection <EnumerationItem>();
            nc.EnumerationList.Last().Items.Add(new EnumerationItem()
            {
                Name = "BIG_ENUM_NAME", Value = 1
            });
            nc.EnumerationList.Last().Items.Add(new EnumerationItem()
            {
                Name = "BIG_ENUM_NAME1", Value = 2
            });
            nc.EnumerationList.Last().Items.Add(new EnumerationItem()
            {
                Name = "BIG_ENUM_NAME2", Value = 4
            });
            nc.EnumerationList.Last().Items.Add(new EnumerationItem()
            {
                Name = "BIG_ENUM_NAME3", Value = 8
            });

            nc.EnumerationList.Add(new EnumerationDefinition());
            nc.EnumerationList.Last().EnumerationName = "TestEnum 2";
            nc.EnumerationList.Last().Items           = new ObservableCollection <EnumerationItem>();
            nc.EnumerationList.Last().Items.Add(new EnumerationItem()
            {
                Name = "BIG_ENUM_NAME", Value = 1
            });
            nc.EnumerationList.Last().Items.Add(new EnumerationItem()
            {
                Name = "BIG_ENUM_NAME3", Value = 8
            });

            var netcmd = CommandVM.NetworkCommands;

            netcmd.Add(new NetworkCommandTreeItemModel()
            {
                CommandName = nc.Name, NetworkCommand = nc
            });
            netcmd.Add(new NetworkCommandTreeItemModel()
            {
                CommandName = nc.Name, NetworkCommand = nc
            });
            netcmd.Add(new NetworkCommandTreeItemModel()
            {
                CommandName = nc.Name, NetworkCommand = nc
            });
            netcmd.Add(new NetworkCommandTreeItemModel()
            {
                CommandName = nc.Name, NetworkCommand = nc
            });
            netcmd.Add(new NetworkCommandTreeItemModel()
            {
                CommandName = nc.Name, NetworkCommand = nc
            });
            netcmd.Add(new NetworkCommandTreeItemModel()
            {
                CommandName = nc.Name, NetworkCommand = nc
            });
            netcmd.Add(new NetworkCommandTreeItemModel()
            {
                CommandName = nc.Name, NetworkCommand = nc
            });
            netcmd.Add(new NetworkCommandTreeItemModel()
            {
                CommandName = nc.Name, NetworkCommand = nc
            });

            var json = Newtonsoft.Json.JsonConvert.SerializeObject(CommandVM, Newtonsoft.Json.Formatting.Indented);
        }