Beispiel #1
0
 /// <summary>
 /// Constructor
 /// </summary>
 public TaskManager()
 {
     Tasks = new ListMapping<RunTime, ITask>();
     foreach (ITask Task in AppDomain.CurrentDomain.GetAssemblies().Objects<ITask>())
     {
         Tasks.Add(Task.TimeToRun, Task);
     }
 }
        /// <summary>
        /// Adds a mapping
        /// </summary>
        /// <param name="Mapping">Mapping to add</param>
        public virtual void AddMapping(IMapping Mapping)
        {
            if (Mappings == null)
            {
                Mappings = new ListMapping <IDatabase, IMapping>();
            }
            IEnumerable <IDatabase> Databases = this.Databases.Where(x => x.IsOfType(Mapping.DatabaseConfigType) &&
                                                                     !string.IsNullOrEmpty(x.ConnectionString));

            foreach (IDatabase Database in Databases)
            {
                Mapping.AddToQueryProvider(Database);
                Mappings.Add(Database, Mapping);
            }
        }
Beispiel #3
0
 /// <summary>
 /// Constructor
 /// </summary>
 public AssetManager()
 {
     Filters        = AppDomain.CurrentDomain.GetAssemblies().Objects <IFilter>();
     ContentFilters = AppDomain.CurrentDomain.GetAssemblies().Objects <IContentFilter>();
     Translators    = AppDomain.CurrentDomain.GetAssemblies().Objects <ITranslator>();
     FileTypes      = new ListMapping <AssetType, string>();
     RunOrder       = new System.Collections.Generic.List <RunTime>();
     Translators.ForEach(x => FileTypes.Add(x.TranslatesTo, x.FileTypeAccepts));
     FileTypes.Add(AssetType.CSS, "css");
     FileTypes.Add(AssetType.Javascript, "js");
     RunOrder.Add(RunTime.PostTranslate);
     RunOrder.Add(RunTime.PreMinified);
     RunOrder.Add(RunTime.Minify);
     RunOrder.Add(RunTime.PostMinified);
     RunOrder.Add(RunTime.PreCombine);
 }
        public void BasicTest()
        {
            var TestObject = new System.Collections.Generic.List <string>();

            TestObject.AddRange(new string[] { "this", "is", "a", "test" });
            ListMapping <int, string> Results = TestObject.Permute();

            Assert.Equal(24, Results.Keys.Count);
            foreach (int Key in Results.Keys)
            {
                foreach (string Item in Results[Key])
                {
                    Assert.True(Item == "this" || Item == "is" || Item == "a" || Item == "test");
                }
            }
        }
Beispiel #5
0
        /// <summary>
        /// Sets up the mappings
        /// </summary>
        /// <param name="AssemblyUsing">Assembly using</param>
        private void Setup(Assembly AssemblyUsing)
        {
            if (Mappings == null)
            {
                Mappings = new ListMapping <Type, IMapping>();
            }
            IEnumerable <Type> Types = AssemblyUsing.GetTypes(typeof(IMapping));

            foreach (Type Type in Types)
            {
                Type     BaseType   = Type.BaseType;
                IMapping TempObject = (IMapping)AssemblyUsing.CreateInstance(Type.FullName);
                TempObject.Manager = this;
                Mappings.Add(BaseType.GetGenericArguments()[0], TempObject);
            }
        }
Beispiel #6
0
 /// <summary>
 /// Constructor
 /// </summary>
 public AssetManager()
 {
     Filters = AppDomain.CurrentDomain.GetAssemblies().Objects<IFilter>();
     ContentFilters = AppDomain.CurrentDomain.GetAssemblies().Objects<IContentFilter>();
     Translators = AppDomain.CurrentDomain.GetAssemblies().Objects<ITranslator>();
     FileTypes = new ListMapping<AssetType, string>();
     RunOrder = new System.Collections.Generic.List<RunTime>();
     Translators.ForEach(x => FileTypes.Add(x.TranslatesTo, x.FileTypeAccepts));
     FileTypes.Add(AssetType.CSS, "css");
     FileTypes.Add(AssetType.Javascript, "js");
     RunOrder.Add(RunTime.PostTranslate);
     RunOrder.Add(RunTime.PreMinified);
     RunOrder.Add(RunTime.Minify);
     RunOrder.Add(RunTime.PostMinified);
     RunOrder.Add(RunTime.PreCombine);
 }
Beispiel #7
0
        /// <summary>
        /// Mapping source
        /// </summary>
        /// <param name="mappings">Mappings associated with the source</param>
        /// <param name="source">Database source</param>
        /// <param name="queryProvider">The query provider.</param>
        /// <param name="logger">Logging object</param>
        /// <param name="objectPool">The object pool.</param>
        /// <exception cref="ArgumentNullException">queryProvider or source</exception>
        public MappingSource(
            IEnumerable <IMapping> mappings,
            IDatabase source,
            QueryProviderManager queryProvider,
            ILogger logger,
            ObjectPool <StringBuilder> objectPool)
        {
            Source = source ?? throw new ArgumentNullException(nameof(source));
            Logger = logger ?? Log.Logger ?? new LoggerConfiguration().CreateLogger() ?? throw new ArgumentNullException(nameof(logger));
            Logger.Information("Setting up {Name:l}", source.Name);

            QueryProvider = queryProvider ?? throw new ArgumentNullException(nameof(queryProvider));
            ConcreteTypes = Array.Empty <Type>();
            mappings ??= Array.Empty <IMapping>();

            IsDebug = Logger.IsEnabled(LogEventLevel.Debug);
            var TempSourceOptions = Source.SourceOptions;

            if (!(TempSourceOptions is null))
            {
                CanRead          = (TempSourceOptions.Access & SourceAccess.Read) != 0;
                CanWrite         = (TempSourceOptions.Access & SourceAccess.Write) != 0;
                ApplyAnalysis    = TempSourceOptions.Analysis == SchemaAnalysis.ApplyAnalysis;
                GenerateAnalysis = TempSourceOptions.Analysis == SchemaAnalysis.GenerateAnalysis;
                GenerateSchema   = TempSourceOptions.SchemaUpdate == SchemaGeneration.GenerateSchemaChanges;
                UpdateSchema     = TempSourceOptions.SchemaUpdate == SchemaGeneration.UpdateSchema;
                Optimize         = TempSourceOptions.Optimize;
            }

            Order = Source.Order;

            ChildTypes  = new ListMapping <Type, Type>();
            ParentTypes = new ListMapping <Type, Type>();
            ObjectPool  = objectPool;

            Logger.Information("Adding mappings for {Name:l}", Source.Name);
            Mappings = mappings.ToDictionary(x => x.ObjectType);
            Logger.Information("Setting up type graphs for {Name:l}", Source.Name);
            TypeGraphs = Mappings.ToDictionary(Item => Item.Key, Item => Generator.Generate(Item.Key, Mappings));

            SetupChildTypes();
            MergeMappings();
            SetupParentTypes();
            ReduceMappings();
            RemoveDeadMappings();
            SetupAutoIDs();
        }
        /// <summary>
        /// Finds all permutations of the items within the list
        /// </summary>
        /// <typeparam name="T">Object type in the list</typeparam>
        /// <param name="Input">Input list</param>
        /// <returns>The list of permutations</returns>
        public static ListMapping <int, T> Permute <T>(this IEnumerable <T> Input)
        {
            if (Input == null)
            {
                throw new ArgumentNullException("Input");
            }
            System.Collections.Generic.List <T> Current = new System.Collections.Generic.List <T>();
            Current.AddRange(Input);
            ListMapping <int, T> ReturnValue = new ListMapping <int, T>();
            int Max          = (Input.Count() - 1).Factorial();
            int CurrentValue = 0;

            for (int x = 0; x < Input.Count(); ++x)
            {
                int z = 0;
                while (z < Max)
                {
                    int y = Input.Count() - 1;
                    while (y > 1)
                    {
                        T TempHolder = Current[y - 1];
                        Current[y - 1] = Current[y];
                        Current[y]     = TempHolder;
                        --y;
                        foreach (T Item in Current)
                        {
                            ReturnValue.Add(CurrentValue, Item);
                        }
                        ++z;
                        ++CurrentValue;
                        if (z == Max)
                        {
                            break;
                        }
                    }
                }
                if (x + 1 != Input.Count())
                {
                    Current.Clear();
                    Current.AddRange(Input);
                    T TempHolder2 = Current[0];
                    Current[0]     = Current[x + 1];
                    Current[x + 1] = TempHolder2;
                }
            }
            return(ReturnValue);
        }
Beispiel #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MappingManager"/> class.
        /// </summary>
        /// <param name="mappings">The mappings.</param>
        /// <param name="sources">The sources.</param>
        /// <param name="queryProvider">The query provider.</param>
        /// <param name="logger">The logger.</param>
        /// <param name="objectPool">The object pool.</param>
        /// <exception cref="ArgumentNullException">logger</exception>
        public MappingManager(
            IEnumerable <IMapping> mappings,
            IEnumerable <IDatabase> sources,
            QueryProviderManager queryProvider,
            ILogger logger,
            ObjectPool <StringBuilder> objectPool)
        {
            Logger     = logger ?? Log.Logger ?? new LoggerConfiguration().CreateLogger() ?? throw new ArgumentNullException(nameof(logger));
            ObjectPool = objectPool ?? throw new ArgumentNullException(nameof(objectPool));
            mappings ??= Array.Empty <IMapping>();

            var Debug = Logger.IsEnabled(LogEventLevel.Debug);

            Logger.Information("Setting up mapping information");
            var TempSourceMappings = new ListMapping <Type, IMapping>();

            foreach (var Item in mappings)
            {
                TempSourceMappings.Add(Item.DatabaseConfigType, Item);
            }
            var FinalList = new ConcurrentBag <IMappingSource>();

            TempSourceMappings.Keys.ForEachParallel(Key =>
            {
                FinalList.Add(new MappingSource(TempSourceMappings[Key],
                                                sources.FirstOrDefault(x => x.GetType() == Key),
                                                queryProvider,
                                                Logger,
                                                ObjectPool));
            });
            Sources      = FinalList.OrderBy(x => x.Order).ToArray();
            WriteSources = Sources.Where(x => x.CanWrite).ToArray();
            ReadSources  = Sources.Where(x => x.CanRead).ToArray();
            if (Debug)
            {
                var Builder = ObjectPool.Get();
                Builder.AppendLine("Final Mappings:");
                for (var i = 0; i < Sources.Length; i++)
                {
                    Builder.AppendLine(Sources[i].ToString());
                }
                Logger.Debug("{Info:l}", Builder.ToString());
                ObjectPool.Return(Builder);
            }
        }
        public void RandomTest()
        {
            var TestObject = new ListMapping <string, int>();
            var Rand       = new System.Random();

            for (var x = 0; x < 10; ++x)
            {
                var Name = x.ToString();
                for (var y = 0; y < 5; ++y)
                {
                    var Value = Rand.Next();
                    TestObject.Add(Name, Value);
                    Assert.Equal(y + 1, TestObject[Name].Count());
                    Assert.Contains(Value, TestObject[Name]);
                }
            }
            Assert.Equal(10, TestObject.Count);
        }
        /// <summary>
        /// Sets up the specified database schema
        /// </summary>
        /// <param name="Mappings">The mappings.</param>
        /// <param name="Database">The database.</param>
        /// <param name="QueryProvider">The query provider.</param>
        public void Setup(ListMapping <IDatabase, IMapping> Mappings, IDatabase Database, QueryProvider.Manager QueryProvider)
        {
            ISourceInfo TempSource   = SourceProvider.GetSource(Database.Name);
            var         TempDatabase = new Schema.Default.Database.Database(Regex.Match(TempSource.Connection, "Initial Catalog=(.*?;)").Value.Replace("Initial Catalog=", "").Replace(";", ""));

            SetupTables(Mappings, Database, TempDatabase);
            SetupJoiningTables(Mappings, Database, TempDatabase);
            SetupAuditTables(Database, TempDatabase);

            foreach (ITable Table in TempDatabase.Tables)
            {
                Table.SetupForeignKeys();
            }
            List <string> Commands = GenerateSchema(TempDatabase, SourceProvider.GetSource(Database.Name)).ToList();
            IBatch        Batch    = QueryProvider.Batch(SourceProvider.GetSource(Database.Name));

            for (int x = 0; x < Commands.Count; ++x)
            {
                if (Commands[x].ToUpperInvariant().Contains("CREATE DATABASE"))
                {
                    QueryProvider.Batch(SourceProvider.GetSource(Regex.Replace(SourceProvider.GetSource(Database.Name).Connection, "Initial Catalog=(.*?;)", ""))).AddCommand(null, null, CommandType.Text, Commands[x]).Execute();
                }
                else if (Commands[x].Contains("CREATE TRIGGER") || Commands[x].Contains("CREATE FUNCTION"))
                {
                    if (Batch.CommandCount > 0)
                    {
                        Batch.Execute();
                        Batch = QueryProvider.Batch(SourceProvider.GetSource(Database.Name));
                    }
                    Batch.AddCommand(null, null, CommandType.Text, Commands[x]);
                    if (x < Commands.Count - 1)
                    {
                        Batch.Execute();
                        Batch = QueryProvider.Batch(SourceProvider.GetSource(Database.Name));
                    }
                }
                else
                {
                    Batch.AddCommand(null, null, CommandType.Text, Commands[x]);
                }
            }
            Batch.Execute();
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="Filters">The filters.</param>
 /// <param name="ContentFilters">The content filters.</param>
 /// <param name="Translators">The translators.</param>
 public AssetManager(IEnumerable<IFilter> Filters, IEnumerable<IContentFilter> ContentFilters, IEnumerable<ITranslator> Translators)
 {
     Contract.Requires<ArgumentNullException>(Filters != null, "Filters");
     Contract.Requires<ArgumentNullException>(ContentFilters != null, "ContentFilters");
     Contract.Requires<ArgumentNullException>(Translators != null, "Translators");
     this.Filters = Filters;
     this.ContentFilters = ContentFilters;
     this.Translators = Translators;
     FileTypes = new ListMapping<AssetType, string>();
     RunOrder = new System.Collections.Generic.List<RunTime>();
     Translators.ForEach(x => FileTypes.Add(x.TranslatesTo, x.FileTypeAccepts));
     FileTypes.Add(AssetType.CSS, "css");
     FileTypes.Add(AssetType.Javascript, "js");
     RunOrder.Add(RunTime.PostTranslate);
     RunOrder.Add(RunTime.PreMinified);
     RunOrder.Add(RunTime.Minify);
     RunOrder.Add(RunTime.PostMinified);
     RunOrder.Add(RunTime.PreCombine);
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="Filters">The filters.</param>
 /// <param name="ContentFilters">The content filters.</param>
 /// <param name="Translators">The translators.</param>
 public AssetManager(IEnumerable <IFilter> Filters, IEnumerable <IContentFilter> ContentFilters, IEnumerable <ITranslator> Translators)
 {
     Contract.Requires <ArgumentNullException>(Filters != null, "Filters");
     Contract.Requires <ArgumentNullException>(ContentFilters != null, "ContentFilters");
     Contract.Requires <ArgumentNullException>(Translators != null, "Translators");
     this.Filters        = Filters;
     this.ContentFilters = ContentFilters;
     this.Translators    = Translators;
     FileTypes           = new ListMapping <AssetType, string>();
     RunOrder            = new System.Collections.Generic.List <RunTime>();
     Translators.ForEach(x => FileTypes.Add(x.TranslatesTo, x.FileTypeAccepts));
     FileTypes.Add(AssetType.CSS, "css");
     FileTypes.Add(AssetType.Javascript, "js");
     RunOrder.Add(RunTime.PostTranslate);
     RunOrder.Add(RunTime.PreMinified);
     RunOrder.Add(RunTime.Minify);
     RunOrder.Add(RunTime.PostMinified);
     RunOrder.Add(RunTime.PreCombine);
 }
            public PartSelectionWindow(Printer printer, ListMapping<PartCategories, AvailablePart> availableParts) : base(printer.part)
            {
                _printer = printer;
                Title = "Choose part to print";

                AddControl(new KspUIVerticalLayout().Tap(xx =>
                {
                    xx.AddControl(new KspUIHorizontalLayout().Tap(x =>
                    {
                        x.AddControl(new KspUIScroll().Tap(y =>
                        {
                            y.MinWidth = 300;
                            y.MinHeight = 600;
                            y.AddControl(KspUIRepeat.Create(() => availableParts.Keys, z => new KspUIButton(z.ToString(), () =>
                            {
                                _selectedCategory = z;
                            })));
                        }));

                        x.AddControl(new KspUIScroll().Tap(y =>
                        {
                            y.MinWidth = 600;
                            y.MinHeight = 600;

                            y.AddControl(KspUIRepeat.Create(() => availableParts[_selectedCategory], z =>
                            {
                                float oreUnitsRequired = _printer.GetRequiredOreUnits(z);
                                return new KspUIButton(z.title + Environment.NewLine + oreUnitsRequired + " ore units required", () =>
                                {
                                    Close();
                                    _printer.BuildingPart = z;
                                    _printer.MassPrinted = 0;
                                    _printer.StartWork();
                                });
                            }));
                        }));
                    }));

                    xx.AddControl(new KspUIButton("Close", Close));
                }));
            }
Beispiel #15
0
 /// <summary>
 /// Gets a list of types based on an interface from all assemblies found in a directory
 /// </summary>
 /// <param name="AssemblyDirectory">Directory to search in</param>
 /// <param name="Interface">The interface to look for</param>
 /// <returns>A list mapping using the assembly as the key and a list of types</returns>
 public static ListMapping<Assembly, Type> GetTypesFromDirectory(string AssemblyDirectory, string Interface)
 {
     ListMapping<Assembly, Type> ReturnList = new ListMapping<Assembly,Type>();
     System.Collections.Generic.List<Assembly> Assemblies = GetAssembliesFromDirectory(AssemblyDirectory);
     foreach (Assembly Assembly in Assemblies)
     {
         Type[] Types = Assembly.GetTypes();
         foreach (Type Type in Types)
         {
             if (Type.GetInterface(Interface, true) != null)
             {
                 ReturnList.Add(Assembly, Type);
             }
         }
     }
     return ReturnList;
 }
 private static void SetupTables(ListMapping<IDatabase, IMapping> Mappings, IDatabase Key, Database TempDatabase, Graph<IMapping> Structure)
 {
     Contract.Requires<NullReferenceException>(Mappings != null, "Mappings");
     foreach (IMapping Mapping in Mappings[Key].OrderBy(x => x.Order))
     {
         TempDatabase.AddTable(Mapping.TableName);
         SetupProperties(TempDatabase[Mapping.TableName], Mapping);
     }
     foreach (Vertex<IMapping> Vertex in Structure.Where(x => x.OutgoingEdges.Count > 0))
     {
         var Mapping = Vertex.Data;
         var ForeignMappings = Vertex.OutgoingEdges.Select(x => x.Sink.Data);
         foreach (var Property in Mapping.IDProperties)
         {
             foreach (var ForeignMapping in ForeignMappings)
             {
                 var ForeignProperty = ForeignMapping.IDProperties.FirstOrDefault(x => x.Name == Property.Name);
                 if (ForeignProperty != null)
                 {
                     TempDatabase[Mapping.TableName].AddForeignKey(Property.FieldName, ForeignMapping.TableName, ForeignProperty.FieldName);
                 }
             }
         }
     }
 }
        /// <summary>
        /// Sets up the specified database schema
        /// </summary>
        /// <param name="Mappings">The mappings.</param>
        /// <param name="Database">The database.</param>
        /// <param name="QueryProvider">The query provider.</param>
        public void Setup(ListMapping<IDatabase, IMapping> Mappings, IDatabase Database, Utilities.ORM.Manager.QueryProvider.Manager QueryProvider, Graph<IMapping> Structure)
        {
            var TempSource = SourceProvider.GetSource(Database.Name);
            var TempDatabase = new Utilities.ORM.Manager.Schema.Default.Database.Database(Regex.Match(TempSource.Connection, "Initial Catalog=(.*?;)").Value.Replace("Initial Catalog=", "").Replace(";", ""));
            SetupTables(Mappings, Database, TempDatabase);
            SetupJoiningTables(Mappings, Database, TempDatabase);
            SetupAuditTables(Database, TempDatabase);

            foreach (ITable Table in TempDatabase.Tables)
            {
                Table.SetupForeignKeys();
            }
            var Commands = GenerateSchema(TempDatabase, SourceProvider.GetSource(Database.Name)).ToList();
            var Batch = QueryProvider.Batch(SourceProvider.GetSource(Database.Name));
            for (int x = 0; x < Commands.Count; ++x)
            {
                if (Commands[x].ToUpperInvariant().Contains("CREATE DATABASE"))
                {
                    QueryProvider.Batch(SourceProvider.GetSource(Regex.Replace(SourceProvider.GetSource(Database.Name).Connection, "Initial Catalog=(.*?;)", ""))).AddCommand(null, null, CommandType.Text, Commands[x]).Execute();
                }
                else if (Commands[x].Contains("CREATE TRIGGER") || Commands[x].Contains("CREATE FUNCTION"))
                {
                    if (Batch.CommandCount > 0)
                    {
                        Batch.Execute();
                        Batch = QueryProvider.Batch(SourceProvider.GetSource(Database.Name));
                    }
                    Batch.AddCommand(null, null, CommandType.Text, Commands[x]);
                    if (x < Commands.Count - 1)
                    {
                        Batch.Execute();
                        Batch = QueryProvider.Batch(SourceProvider.GetSource(Database.Name));
                    }
                }
                else
                {
                    Batch.AddCommand(null, null, CommandType.Text, Commands[x]);
                }
            }
            Batch.Execute();
        }
 private static void SetupJoiningTablesEnumerable(ListMapping<IDatabase, IMapping> Mappings, IMapping Mapping, IProperty Property, IDatabase Key, Utilities.ORM.Manager.Schema.Default.Database.Database TempDatabase)
 {
     Contract.Requires<ArgumentNullException>(TempDatabase != null, "TempDatabase");
     Contract.Requires<ArgumentNullException>(TempDatabase.Tables != null, "TempDatabase.Tables");
     if (TempDatabase.Tables.FirstOrDefault(x => x.Name == Property.TableName) != null)
         return;
     var MapMapping = Mappings[Key].FirstOrDefault(x => x.ObjectType == Property.Type);
     if (MapMapping == null)
         return;
     if (MapMapping == Mapping)
     {
         TempDatabase.AddTable(Property.TableName);
         TempDatabase[Property.TableName].AddColumn("ID_", DbType.Int32, 0, false, true, true, true, false, "", "", "");
         TempDatabase[Property.TableName].AddColumn(Mapping.TableName + Mapping.IDProperties.First().FieldName,
             Mapping.IDProperties.First().Type.To(DbType.Int32),
             Mapping.IDProperties.First().MaxLength,
             false,
             false,
             false,
             false,
             false,
             Mapping.TableName,
             Mapping.IDProperties.First().FieldName,
             "",
             false,
             false,
             false);
         TempDatabase[Property.TableName].AddColumn(MapMapping.TableName + MapMapping.IDProperties.First().FieldName + "2",
             MapMapping.IDProperties.First().Type.To(DbType.Int32),
             MapMapping.IDProperties.First().MaxLength,
             false,
             false,
             false,
             false,
             false,
             MapMapping.TableName,
             MapMapping.IDProperties.First().FieldName,
             "",
             false,
             false,
             false);
     }
     else
     {
         TempDatabase.AddTable(Property.TableName);
         TempDatabase[Property.TableName].AddColumn("ID_", DbType.Int32, 0, false, true, true, true, false, "", "", "");
         TempDatabase[Property.TableName].AddColumn(Mapping.TableName + Mapping.IDProperties.First().FieldName,
             Mapping.IDProperties.First().Type.To(DbType.Int32),
             Mapping.IDProperties.First().MaxLength,
             false,
             false,
             false,
             false,
             false,
             Mapping.TableName,
             Mapping.IDProperties.First().FieldName,
             "",
             true,
             false,
             false);
         TempDatabase[Property.TableName].AddColumn(MapMapping.TableName + MapMapping.IDProperties.First().FieldName,
             MapMapping.IDProperties.First().Type.To(DbType.Int32),
             MapMapping.IDProperties.First().MaxLength,
             false,
             false,
             false,
             false,
             false,
             MapMapping.TableName,
             MapMapping.IDProperties.First().FieldName,
             "",
             true,
             false,
             false);
     }
 }
        private ListMapping<PartCategories, AvailablePart> AvailablePartsForPrinting()
        {
            ListMapping<PartCategories, AvailablePart> ret = new ListMapping<PartCategories, AvailablePart>();
            AvailablePart[] availableParts = PartLoader.LoadedPartsList.ToArray();

            foreach (AvailablePart availablePart in availableParts)
            {
                KISItemModuleWrapper mki = KISItemModuleWrapper.FromComponent(availablePart.partPrefab.GetComponent("ModuleKISItem"));
                if (mki != null)
                {
                    if (mki.VolumeOverride <= Inventory.MaxVolume)
                        ret.Add(availablePart.category, availablePart);
                }
                else
                {
                    try
                    {
                        if (availablePart.partPrefab.GetVolume() <= Inventory.MaxVolume)
                            ret.Add(availablePart.category, availablePart);
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            return ret;
        }
 /// <summary>
 /// Constructor
 /// </summary>
 protected CacheBase()
 {
     TagMappings = new ListMapping<string, string>();
 }
 /// <summary>
 /// Sets up the specified database schema
 /// </summary>
 /// <param name="Mappings">The mappings.</param>
 /// <param name="Database">The database.</param>
 /// <param name="QueryProvider">The query provider.</param>
 public void Setup(ListMapping<IDatabase, IMapping> Mappings, IDatabase Database, QueryProvider.Manager QueryProvider)
 {
 }
Beispiel #22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Workflow{T}"/> class.
 /// </summary>
 /// <param name="Name">The name.</param>
 public Workflow(string Name)
 {
     this.Name        = Name;
     this.Nodes       = new List <IWorkflowNode <T> >();
     ExceptionActions = new ListMapping <Type, Action <T> >();
 }
 /// <summary>
 /// Sets up the mappings
 /// </summary>
 /// <param name="AssemblyUsing">Assembly using</param>
 private void Setup(Assembly AssemblyUsing)
 {
     if (Mappings == null)
         Mappings = new ListMapping<Type, IMapping>();
     IEnumerable<Type> Types = AssemblyUsing.GetTypes(typeof(IMapping));
     foreach (Type Type in Types)
     {
         Type BaseType = Type.BaseType;
         IMapping TempObject = (IMapping)AssemblyUsing.CreateInstance(Type.FullName);
         TempObject.Manager = this;
         Mappings.Add(BaseType.GetGenericArguments()[0], TempObject);
     }
 }
        private static void SetupJoiningTablesEnumerable(ListMapping <IDatabase, IMapping> Mappings, IMapping Mapping, IProperty Property, IDatabase Key, Schema.Default.Database.Database TempDatabase)
        {
            Contract.Requires <ArgumentNullException>(TempDatabase != null, "TempDatabase");
            Contract.Requires <ArgumentNullException>(TempDatabase.Tables != null, "TempDatabase.Tables");
            if (TempDatabase.Tables.FirstOrDefault(x => x.Name == Property.TableName) != null)
            {
                return;
            }
            IMapping MapMapping = Mappings[Key].FirstOrDefault(x => x.ObjectType == Property.Type);

            if (MapMapping == null)
            {
                return;
            }
            if (MapMapping == Mapping)
            {
                TempDatabase.AddTable(Property.TableName);
                TempDatabase[Property.TableName].AddColumn("ID_", DbType.Int32, 0, false, true, true, true, false, "", "", "");
                TempDatabase[Property.TableName].AddColumn(Mapping.TableName + Mapping.IDProperties.First().FieldName,
                                                           Mapping.IDProperties.First().Type.To(DbType.Int32),
                                                           Mapping.IDProperties.First().MaxLength,
                                                           false,
                                                           false,
                                                           false,
                                                           false,
                                                           false,
                                                           Mapping.TableName,
                                                           Mapping.IDProperties.First().FieldName,
                                                           "",
                                                           false,
                                                           false,
                                                           false);
                TempDatabase[Property.TableName].AddColumn(MapMapping.TableName + MapMapping.IDProperties.First().FieldName + "2",
                                                           MapMapping.IDProperties.First().Type.To(DbType.Int32),
                                                           MapMapping.IDProperties.First().MaxLength,
                                                           false,
                                                           false,
                                                           false,
                                                           false,
                                                           false,
                                                           MapMapping.TableName,
                                                           MapMapping.IDProperties.First().FieldName,
                                                           "",
                                                           false,
                                                           false,
                                                           false);
            }
            else
            {
                TempDatabase.AddTable(Property.TableName);
                TempDatabase[Property.TableName].AddColumn("ID_", DbType.Int32, 0, false, true, true, true, false, "", "", "");
                TempDatabase[Property.TableName].AddColumn(Mapping.TableName + Mapping.IDProperties.First().FieldName,
                                                           Mapping.IDProperties.First().Type.To(DbType.Int32),
                                                           Mapping.IDProperties.First().MaxLength,
                                                           false,
                                                           false,
                                                           false,
                                                           false,
                                                           false,
                                                           Mapping.TableName,
                                                           Mapping.IDProperties.First().FieldName,
                                                           "",
                                                           true,
                                                           false,
                                                           false);
                TempDatabase[Property.TableName].AddColumn(MapMapping.TableName + MapMapping.IDProperties.First().FieldName,
                                                           MapMapping.IDProperties.First().Type.To(DbType.Int32),
                                                           MapMapping.IDProperties.First().MaxLength,
                                                           false,
                                                           false,
                                                           false,
                                                           false,
                                                           false,
                                                           MapMapping.TableName,
                                                           MapMapping.IDProperties.First().FieldName,
                                                           "",
                                                           true,
                                                           false,
                                                           false);
            }
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="Mappings">Mappings associated with databases (provided by query provider)</param>
 public DatabaseManager(ListMapping <IDatabase, IMapping> Mappings)
 {
     this.Mappings           = Mappings;
     this.DatabaseStructures = new System.Collections.Generic.List <SQL.DataClasses.Database>();
 }
Beispiel #26
0
 public ListInspector(ListMapping mapping)
     : base(mapping)
 {
     this.mapping = mapping;
     mappedProperties.Map(x => x.LazyLoad, x => x.Lazy);
 }
 public ListInstance(ListMapping mapping)
     : base(mapping)
 {
     this.mapping = mapping;
 }
        public override void ProcessList(ListMapping mapping)
        {
            var writer = serviceLocator.GetWriter <ListMapping>();

            document = writer.Write(mapping);
        }
        public void MutableShouldBeTrueByDefaultOnListMapping()
        {
            var mapping = new ListMapping();

            mapping.Mutable.ShouldBeTrue();
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="Mappings">Mappings associated with databases (provided by query provider)</param>
 public DatabaseManager(ListMapping<IDatabase, IMapping> Mappings)
 {
     this.Mappings = Mappings;
     this.DatabaseStructures = new System.Collections.Generic.List<SQL.DataClasses.Database>();
 }
        private void SyncRow(ProviderSqlDynamic provider, Tuple <int, ExpandoObject> value, ListMapping mapping)
        {
            var updateData = (IDictionary <string, object>) new ExpandoObject();
            var valueData  = (IDictionary <string, object>)value.Item2;

            updateData.Add(mapping.Key, value.Item1);
            mapping.ListMappingFields.ToList().ForEach(item =>
            {
                updateData.Add(item.FieldName, valueData[item.ItemName]);
            });

            if (provider.IsExists(value.Item1))
            {
                provider.UpdateRow((ExpandoObject)updateData);
            }
            else
            {
                provider.CreateRow((ExpandoObject)updateData);
            }
        }
Beispiel #32
0
 /// <summary>
 /// Sets up the specified databases
 /// </summary>
 /// <param name="Mappings">The mappings.</param>
 /// <param name="QueryProvider">The query provider.</param>
 /// <param name="Database">The database.</param>
 /// <param name="Source">The source.</param>
 /// <param name="Structure">The structure.</param>
 public void Setup(ListMapping <IDatabase, IMapping> Mappings, QueryProvider.Manager QueryProvider, IDatabase Database, ISourceInfo Source, Graph <IMapping> Structure)
 {
     Contract.Requires <NullReferenceException>(Mappings != null, "Mappings");
     SchemaGenerators[Source.SourceType].Setup(Mappings, Database, QueryProvider, Structure);
 }
Beispiel #33
0
 public void CreateDsl()
 {
     mapping   = new ListMapping();
     inspector = new ListInspector(mapping);
 }
Beispiel #34
0
 /// <summary>
 /// Sets up the specified database schema
 /// </summary>
 /// <param name="Mappings">The mappings.</param>
 /// <param name="Database">The database.</param>
 /// <param name="QueryProvider">The query provider.</param>
 /// <param name="Structure">The structure.</param>
 public void Setup(ListMapping <IDatabase, IMapping> Mappings, IDatabase Database, QueryProvider.Manager QueryProvider, Graph <IMapping> Structure)
 {
 }
 public override void ProcessList(ListMapping listMapping)
 {
     ProcessCollection(listMapping);
 }
 /// <summary>
 /// Constructor
 /// </summary>
 protected CacheBase()
     : base()
 {
     TagMappings = new ListMapping <string, string>();
 }
 /// <summary>
 /// Sets up the specified database schema
 /// </summary>
 /// <param name="Mappings">The mappings.</param>
 /// <param name="Database">The database.</param>
 /// <param name="QueryProvider">The query provider.</param>
 public void Setup(ListMapping <IDatabase, IMapping> Mappings, IDatabase Database, QueryProvider.Manager QueryProvider)
 {
 }
 private static void SetupJoiningTables(ListMapping<IDatabase, IMapping> Mappings, IDatabase Key, Utilities.ORM.Manager.Schema.Default.Database.Database TempDatabase)
 {
     Contract.Requires<NullReferenceException>(Mappings != null, "Mappings");
     foreach (IMapping Mapping in Mappings[Key])
     {
         foreach (IProperty Property in Mapping.Properties)
         {
             if (Property is IMap)
             {
                 var MapMapping = Mappings[Key].FirstOrDefault(x => x.ObjectType == Property.Type);
                 foreach (IProperty IDProperty in MapMapping.IDProperties)
                 {
                     TempDatabase[Mapping.TableName].AddColumn(Property.FieldName,
                         IDProperty.Type.To(DbType.Int32),
                         IDProperty.MaxLength,
                         !Property.NotNull,
                         false,
                         Property.Index,
                         false,
                         false,
                         MapMapping.TableName,
                         IDProperty.FieldName,
                         "",
                         false,
                         false,
                         Mapping.Properties.Count(x => x.Type == Property.Type) == 1 && Mapping.ObjectType != Property.Type);
                 }
             }
             else if (Property is IManyToOne || Property is IManyToMany || Property is IIEnumerableManyToOne || Property is IListManyToMany || Property is IListManyToOne)
             {
                 SetupJoiningTablesEnumerable(Mappings, Mapping, Property, Key, TempDatabase);
             }
         }
     }
 }
 /// <summary>
 /// Sets up the specified databases
 /// </summary>
 /// <param name="Mappings">The mappings.</param>
 /// <param name="QueryProvider">The query provider.</param>
 /// <param name="Database">The database.</param>
 /// <param name="Source">The source.</param>
 /// <param name="Structure">The structure.</param>
 public void Setup(ListMapping<IDatabase, IMapping> Mappings, QueryProvider.Manager QueryProvider, IDatabase Database, ISourceInfo Source, Graph<IMapping> Structure)
 {
     Contract.Requires<NullReferenceException>(Mappings != null, "Mappings");
     SchemaGenerators[Source.SourceType].Setup(Mappings, Database, QueryProvider, Structure);
 }
 private static void SetupTables(ListMapping<IDatabase, IMapping> Mappings, IDatabase Key, Utilities.ORM.Manager.Schema.Default.Database.Database TempDatabase)
 {
     Contract.Requires<NullReferenceException>(Mappings != null, "Mappings");
     foreach (IMapping Mapping in Mappings[Key])
     {
         TempDatabase.AddTable(Mapping.TableName);
         SetupProperties(TempDatabase[Mapping.TableName], Mapping);
     }
 }
        public KspUIHorizontalLayoutX(ListMapping<PartCategories, AvailablePart> availableParts, Printer printer)
        {
            _availableParts = availableParts;
            _printer = printer;

        }
Beispiel #42
0
 public virtual void ProcessList(ListMapping listMapping)
 {
 }
Beispiel #43
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BrillTagger"/> class.
 /// </summary>
 public BrillTagger()
 {
     Lexicon = new ListMapping <string, string>();
     BuildLexicon();
 }
        public static Tuple <int, ExpandoObject> ToSyncObject(this SPListItem listItem, ListMapping mapping)
        {
            var result = (IDictionary <string, object>) new ExpandoObject();

            mapping.ListMappingFields.ToList().ForEach(item =>
            {
                var spField = item.ItemName.IsGuid() ? listItem.FieldById(item.ItemName.ToGuid()) : listItem.FieldByName(item.ItemName);
                object spItemValue;
                try {
                    spItemValue = (spField != null) ? listItem.GetObjectValue(spField) : string.Empty;
                } catch {
                    spItemValue = string.Empty;
                }
                result.Add(item.ItemName, spItemValue);
            });
            return(new Tuple <int, ExpandoObject>(listItem.ID, (ExpandoObject)result));
        }
 /// <summary>
 /// Sets up the specified database schema
 /// </summary>
 /// <param name="Mappings">The mappings.</param>
 /// <param name="Database">The database.</param>
 /// <param name="QueryProvider">The query provider.</param>
 /// <param name="Structure">The structure.</param>
 public void Setup(ListMapping<IDatabase, IMapping> Mappings, IDatabase Database, QueryProvider.Manager QueryProvider, Graph<IMapping> Structure)
 {
 }