Esempio n. 1
0
        public T GetOrCreateModule <T>() where T : KalkModule, new()
        {
            var typeOfT = typeof(T);

            if (_modules.TryGetValue(typeOfT, out var module))
            {
                return((T)module);
            }
            var moduleT = new T();

            module = moduleT;
            _modules.Add(typeOfT, module);

            if (!module.IsBuiltin)
            {
                Builtins.SetValue(module.Name, module, true);
                // Register the module descriptor
                Descriptors.Add(module.Name, module.Descriptor);
            }

            module.Initialize(this);

            if (module.IsBuiltin)
            {
                module.InternalImport();
            }

            return(moduleT);
        }
Esempio n. 2
0
        public Spell Ablative_Barrier()
        {
            Name = "Ablative Barrier";

            School     = new Conjuration();
            Sub_School = new Conjuration.Creation();
            Descriptors.Add(new Force());
            Level.Add("Alchemist", 2);
            Level.Add("Bloodrager", 2);
            Level.Add("Magus", 2);
            Level.Add("Occultist", 2);
            Level.Add("Psychic", 3);
            Level.Add("Sorcerer/Wizard", 3);
            Level.Add("Summoner", 2);
            Level.Add("Unchained Summoner", 3);

            Casting_Time = "1 standard action";
            Components.AddRange(new List <string> {
                "V", "S", "M(a piece of metal cut from a shield)"
            });

            Range            = "touch";
            Target           = "creature touched";
            Duration         = "1 hour/level or until discharged";
            Saving_Throw     = "Will negates (harmless)";
            Spell_Resistance = "no";

            Description = "Invisible layers of solid force surround and protect the target, granting that target a +2 armor bonus to AC. Additionally, the first 5 points of lethal damage the target takes from each attack are converted into nonlethal damage. Against attacks that already deal nonlethal damage, the target gains DR 5/—. Once this spell has converted 5 points of damage to nonlethal damage per caster level (maximum 50 points), the spell is discharged.";

            return(this);
        }
Esempio n. 3
0
 public void OnEnable()
 {
     if (!Descriptors.Contains(StateDescriptor.STATIC))
     {
         Descriptors.Add(StateDescriptor.STATIC);
     }
 }
Esempio n. 4
0
        protected void RegisterVariable(string name, object value, string category = null)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }
            var names = name.Split(',');

            KalkDescriptor descriptor = null;

            foreach (var subName in names)
            {
                Content.SetValue(subName, value, true);

                if (descriptor == null || !Descriptors.TryGetValue(names[0], out descriptor))
                {
                    descriptor = new KalkDescriptor();
                }
                Descriptors.Add(subName, descriptor);
                descriptor.Names.Add(subName);
            }
        }
Esempio n. 5
0
 public void BuildNPCFromEmbed(Embed embed)
 {
     foreach (var activityField in embed.Fields.Where(fld => fld.Name == NPCResources.Activity))
     {
         Activities.Add(activityField.Value);
     }
     foreach (var dispositionField in embed.Fields.Where(fld => fld.Name == NPCResources.Disposition))
     {
         Dispositions.Add(dispositionField.Value);
     }
     foreach (var goal in embed.Fields.Where(fld => fld.Name == NPCResources.Goal))
     {
         Goals.Add(goal.Value);
     }
     foreach (var role in embed.Fields.Where(fld => fld.Name == NPCResources.Role))
     {
         Roles.Add(role.Value);
     }
     foreach (var desc in embed.Fields.Where(fld => fld.Name == NPCResources.Descriptor))
     {
         Descriptors.Add(desc.Value);
     }
     Name      = embed.Fields.FirstOrDefault(fld => fld.Name == NPCResources.Name).Value;
     IconUrl   = embed.Thumbnail.HasValue ? embed.Thumbnail.Value.Url : null;
     EmbedDesc = embed.Description;
 }
Esempio n. 6
0
        /// <summary>
        /// Creates a new <see cref="Descriptor"/> from the <see cref="TcpClient"/>.
        /// </summary>
        /// <param name="client">The <see cref="TcpClient"/> to create the descriptor from.</param>
        public async Task NewDescriptorAsync(TcpClient client)
        {
            var newDescriptor = new Descriptor(client);

            Descriptors.Add(newDescriptor);

            await newDescriptor.SendAsync("Username (new for new account): ");
        }
 /// <summary>
 /// Now, this is a fairly trivial, if a bit naive Code Generation implementation. We are
 /// solely interested in making sure that fundamental building blocks of Code Generation,
 /// such as inserting a Leading Preamble Text, are taking place successfully.
 /// </summary>
 /// <inheritdoc />
 public override Task GenerateAsync(DocumentTransformationContext context, IProgress <Diagnostic> progress
                                    , CancellationToken cancellationToken)
 => Task.Run(
     () =>
 {
     Descriptors.Add(new CodeGeneratorDescriptor {
         CompilationUnits = { context.SourceCompilationUnit }
     });
 }, cancellationToken);
Esempio n. 8
0
        /// <summary>
        /// Uses singleton middleware objects.
        /// Same object is used for all requests
        /// </summary>
        public void UseMiddleware(IMiddleware middleware)
        {
            MiddlewareDescriptor desc = new MiddlewareDescriptor
            {
                Instance              = middleware,
                MiddlewareType        = middleware.GetType(),
                ConstructorParameters = null
            };

            Descriptors.Add(desc);
        }
Esempio n. 9
0
 public void Add(Descriptor descriptor)
 {
     if (descriptor.Name == DefaultName)
     {
         Descriptors[0] = descriptor;
     }
     else
     {
         Descriptors.Add(descriptor);
     }
 }
Esempio n. 10
0
        public RelationshipProxy(SoapRelationship soapRelationship)
            : this()
        {
            BaseSoapRelationship = soapRelationship;

            foreach (KeyValuePair <SoapDescriptorType, Guid> nodeDescriptorPair in BaseSoapRelationship.Nodes)
            {
                DescriptorProxy descriptor = new DescriptorProxy(nodeDescriptorPair.Value, nodeDescriptorPair.Key, this, BaseSoapRelationship);

                Descriptors.Add(descriptor);
            }
        }
        /// <summary>
        /// Now, this is a fairly trivial, if a bit naive Code Generation implementation.
        /// We are solely interested in making sure that fundamental building blocks of
        /// Code Generation, such as inserting a Leading Preamble Text, are taking place
        /// successfully.
        /// </summary>
        /// <inheritdoc />
        public override Task GenerateAsync(DocumentTransformationContext context, IProgress <Diagnostic> progress
                                           , CancellationToken cancellationToken)
        {
            const string dispose   = nameof(IDisposable.Dispose);
            const string disposing = nameof(disposing);
            // ReSharper disable once InconsistentNaming
            const string IsDisposed = nameof(IsDisposed);

            IEnumerable <CodeGeneratorDescriptor> Generate()
            {
                var namespaceDecl = context.SourceCompilationUnit.DescendantNodesAndSelf().OfType <NamespaceDeclarationSyntax>().Single();
                var classDecl     = context.SourceCompilationUnit.DescendantNodesAndSelf().OfType <ClassDeclarationSyntax>().Single();

                yield return(new CodeGeneratorDescriptor
                {
                    CompilationUnits =
                    {
                        CompilationUnit()
                        .WithUsings(SingletonList(GetUsingNamespaceDirective <IDisposable>()))
                        .WithMembers(SingletonList <MemberDeclarationSyntax>(
                                         NamespaceDeclaration(namespaceDecl.Name)
                                         .WithMembers(SingletonList <MemberDeclarationSyntax>(
                                                          ClassDeclaration(classDecl.Identifier)
                                                          .WithModifiers(TokenList(PublicKeywordToken, PartialKeywordToken))
                                                          .WithBaseList(BaseList(
                                                                            SingletonSeparatedList <BaseTypeSyntax>(
                                                                                SimpleBaseType(IdentifierName($"I{Buz}"))
                                                                                )
                                                                            ))
                                                          .WithMembers(List(new[]
                        {
                            GetDisposeMethodDecl(dispose,                                              disposing),
                            GetIsDisposedPropertyDecl(IsDisposed),
                            GetDisposeImplementationMethodDecl(dispose,                                IsDisposed)
                        }))
                                                          ))
                                         ))
                    }
                });
            }

            void RunGenerate()
            {
                foreach (var d in Generate())
                {
                    Descriptors.Add(d);
                }
            }

            return(Task.Run(RunGenerate, cancellationToken));
        }
        /// <summary>
        /// Now, this is a fairly trivial, if a bit naive Code Generation implementation.
        /// We are solely interested in making sure that fundamental building blocks of
        /// Code Generation, such as inserting a Leading Preamble Text, are taking place
        /// successfully.
        /// </summary>
        /// <inheritdoc />
        public override Task GenerateAsync(DocumentTransformationContext context, IProgress <Diagnostic> progress
                                           , CancellationToken cancellationToken)
        {
            IEnumerable <CodeGeneratorDescriptor> Generate()
            {
                var namespaceDecl = context.SourceCompilationUnit.DescendantNodesAndSelf().OfType <NamespaceDeclarationSyntax>().Single();
                var classDecl     = context.SourceCompilationUnit.DescendantNodesAndSelf().OfType <ClassDeclarationSyntax>().Single();

                // ReSharper disable once InconsistentNaming
                const string Initialize = nameof(Initialize);
                var          other      = $"{classDecl.Identifier}";

                yield return(new CodeGeneratorDescriptor
                {
                    CompilationUnits =
                    {
                        CompilationUnit()
                        .WithUsings(SingletonList(GetUsingNamespaceDirective <ICloneable>()))
                        .WithMembers(SingletonList <MemberDeclarationSyntax>(
                                         NamespaceDeclaration(namespaceDecl.Name)
                                         .WithMembers(SingletonList <MemberDeclarationSyntax>(
                                                          ClassDeclaration(classDecl.Identifier)
                                                          .WithModifiers(classDecl.Modifiers)
                                                          .WithBaseList(BaseList(
                                                                            SingletonSeparatedList <BaseTypeSyntax>(
                                                                                SimpleBaseType(IdentifierName(nameof(ICloneable)))
                                                                                )
                                                                            ))
                                                          .WithMembers(List(new[]
                        {
                            GetCopyCtorDecl(other, Initialize),
                            GetInitializeMethodDecl(Initialize, other),
                            GetICloneableCloneMethodDecl(other)
                        }))
                                                          ))
                                         ))
                    }
                });
            }

            void RunGenerate()
            {
                foreach (var d in Generate())
                {
                    Descriptors.Add(d);
                }
            }

            return(Task.Run(RunGenerate, cancellationToken));
        }
Esempio n. 13
0
        public WieldedItem(int damage, Texture2D texture = null)
        {
            if (texture == null)
            {
                texture = GameContent.Instance.cursor;
            }
            Team = Team.Friend;
            // Damage = damage;
            var Knockback = new Vector2(4, 3);
            var halfsize  = new Vector2(3, 25);

            Descriptors.Add(Descriptor.HandSlot);
            Components.Add(new PhysicsComponent(this, Vector2.Zero, halfsize, new Vector2(0.5f, 0.1f)));
            Components.Add(new RenderComponent(this, Color.White, texture));
            Components.Add(new MeleeDamageHitComponent(this, damage, Knockback));
        }
Esempio n. 14
0
        public ChaosOrb(Texture2D texture = null)
        {
            if (texture == null)
            {
                texture = GameContent.Instance.chaos_orb;
            }
            Team = Team.Friend;
            // Damage = damage;
            var halfsize = new Vector2(25, 25);

            Descriptors.Add(Descriptor.ChannelSlot);
            Components.Add(new PhysicsComponent(this, Vector2.Zero, halfsize, new Vector2(0.5f, 0.1f)));
            Components.Add(new GlowingRenderComponent(this, Color.White, texture)
            {
                Radius = 200
            });
        }
Esempio n. 15
0
 /// <summary>
 /// 初始化类<see cref="ExcelEnumerable{TModel}"/>。
 /// </summary>
 public ExcelEnumerable()
 {
     SheetName  = typeof(TModel).GetCustomAttribute <ExcelSheetAttribute>()?.SheetName ?? "sheet1";
     EntityType = typeof(TModel).GetEntityType();
     foreach (var property in EntityType.GetProperties())
     {
         if (property.PropertyInfo.IsDefined(typeof(ExcelColumnAttribute)) ||
             property.PropertyInfo.IsDefined(typeof(ExcelAttribute)))
         {
             Descriptors.Add(new ExcelColumnDescriptor(property));
         }
     }
     if (Columns == 0)
     {
         throw new Exception($"当前类型“{typeof(TModel)}”没有任何属性有使用“{typeof(ExcelAttribute)}”或者“{typeof(ExcelColumnAttribute)}”标记。");
     }
 }
Esempio n. 16
0
        public Shield(Texture2D texture = null)
        {
            if (texture == null)
            {
                texture = GameContent.Instance.shield;
            }
            Team = Team.Friend;
            // Damage = damage;
            var halfsize = new Vector2(10, 32);

            Descriptors.Add(Descriptor.HandSlot);
            Components.Add(new PhysicsComponent(this, Vector2.Zero, halfsize, new Vector2(0.5f, 0.1f))
            {
                Hittable = true
            });
            Components.Add(new RenderComponent(this, Color.White, texture, 2));
        }
Esempio n. 17
0
        /// <summary>
        /// Uses middleware, creates new instance for per request.
        /// </summary>
        public void UseMiddleware <TMiddleware>() where TMiddleware : IMiddleware
        {
            ConstructorInfo ctor = typeof(TMiddleware).GetConstructors().FirstOrDefault();

            if (ctor == null)
            {
                throw new ArgumentException(typeof(TMiddleware) + " has no acceptable constructor");
            }

            MiddlewareDescriptor desc = new MiddlewareDescriptor
            {
                Instance              = null,
                MiddlewareType        = typeof(TMiddleware),
                ConstructorParameters = ctor.GetParameters().Select(x => x.ParameterType).ToArray()
            };

            Descriptors.Add(desc);
        }
        /// <inheritdoc />
        public override Task GenerateAsync(AssemblyTransformationContext context, IProgress <Diagnostic> progress, CancellationToken cancellationToken)
        {
            var s = Service;

            void GenerateCallback()
            {
                // TODO: TBD: sprinkles in a bit of Validation as well...
                // TODO: TBD: would be better if 'Validation' actually supported a more Fluent style...
                Assumes.Present(s);

                // A lot goes in behind the Descriptor parsing the Protocol Buffer file into a usable form.
                var pd      = s.Descriptor;
                var visitor = s.CodeGenerationVisitor;

                Assumes.Present(pd);
                Assumes.Present(visitor);

                // Then we want to Visit the Descriptor to glean the critical details for CG.
                visitor.Visit(pd);

                // ReSharper disable once RedundantEmptyObjectOrCollectionInitializer
                var cgd = new CodeGeneratorDescriptor {
                };

                Assumes.NotNullOrEmpty(visitor.CompilationUnits);
                Assumes.NotNullOrEmpty(cgd.CompilationUnits);

                foreach (var(k, x) in visitor.CompilationUnits)
                {
                    // TODO: TBD: potential future direction for CGR, we may work by adding a dictionary of CompilationUnitSyntax instances...
                    Verify.Operation(k != Guid.Empty, $"Dictionary key '{nameof(k)}' should not be Empty.");
                    Assumes.NotNull(x);

                    cgd.CompilationUnits.Add(x);
                }

                Assumes.Present(Descriptors);

                Descriptors.Add(cgd);
            }

            return(Task.Run(GenerateCallback, cancellationToken));
        }
Esempio n. 19
0
        /// <summary>
        /// Now, this is a fairly trivial, if a bit naive Code Generation implementation.
        /// We are solely interested in making sure that fundamental building blocks of
        /// Code Generation, such as inserting a Leading Preamble Text, are taking place
        /// successfully.
        /// </summary>
        /// <inheritdoc />
        public override Task GenerateAsync(AssemblyTransformationContext context, IProgress <Diagnostic> progress
                                           , CancellationToken cancellationToken)
        {
            // ReSharper disable InconsistentNaming
            const string Foo       = nameof(Foo);
            const string FruitKind = nameof(FruitKind);
            const string Apple     = nameof(Apple);
            const string Orange    = nameof(Orange);
            const string Banana    = nameof(Banana);
            const string Lime      = nameof(Lime);
            const string Lemon     = nameof(Lemon);
            const string Cherry    = nameof(Cherry);

            // ReSharper restore InconsistentNaming

            IEnumerable <CodeGeneratorDescriptor> Generate()
            {
                yield return(new CodeGeneratorDescriptor
                {
                    CompilationUnits =
                    {
                        CompilationUnit()
                        .WithMembers(SingletonList <MemberDeclarationSyntax>(
                                         GetNameSpace(Foo)
                                         .WithMembers(SingletonList <MemberDeclarationSyntax>(
                                                          GetEnumeration(FruitKind, Apple, Orange, Banana, Lime, Lemon, Cherry)
                                                          ))
                                         ))
                    }
                });
            }

            void RunGenerate()
            {
                foreach (var d in Generate())
                {
                    Descriptors.Add(d);
                }
            }

            return(Task.Run(RunGenerate, cancellationToken));
        }
        private async Task GetAllDescriptors()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("ObservableGattCharacteristics::getAllDescriptors: ");
            sb.Append(Name);

            try
            {
                GattDescriptorsResult result = await characteristic.GetDescriptorsAsync(Services.SettingsServices.SettingsService.Instance.UseCaching?BluetoothCacheMode.Cached : BluetoothCacheMode.Uncached);

                if (result.Status == GattCommunicationStatus.Success)
                {
                    sb.Append(" - found ");
                    sb.Append(result.Descriptors.Count);
                    sb.Append(" descriptors");
                    Debug.WriteLine(sb);
                    foreach (GattDescriptor descriptor in result.Descriptors)
                    {
                        ObservableGattDescriptors temp = new ObservableGattDescriptors(descriptor, this);
                        await temp.Initialize();

                        Descriptors.Add(temp);
                    }
                }
                else if (result.Status == GattCommunicationStatus.Unreachable)
                {
                    sb.Append(" - failed with Unreachable");
                    Debug.WriteLine(sb.ToString());
                }
                else if (result.Status == GattCommunicationStatus.ProtocolError)
                {
                    sb.Append(" - failed with ProtocolError");
                    Debug.WriteLine(sb.ToString());
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(" - Exception: {0}" + ex.Message);
                Value = "Unknown (exception: " + ex.Message + ")";
            }
        }
Esempio n. 21
0
        private async void GetAllDescriptors()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("ObservableGattCharacteristics::getAllDescriptors: ");
            sb.Append(Name);

            try
            {
                GattDescriptorsResult result = await Characteristic.GetDescriptorsAsync(Parent.CacheMode);

                if (result.Status == GattCommunicationStatus.Success)
                {
                    sb.Append(" - found ");
                    sb.Append(result.Descriptors.Count);
                    sb.Append(" descriptors");
                    Debug.WriteLine(sb);
                    foreach (GattDescriptor descriptor in result.Descriptors)
                    {
                        Descriptors.Add(new ObservableGattDescriptors(descriptor, this));
                    }
                }
                else if (result.Status == GattCommunicationStatus.Unreachable)
                {
                    sb.Append(" - failed with Unreachable");
                    Debug.WriteLine(sb.ToString());
                }
                else if (result.Status == GattCommunicationStatus.ProtocolError)
                {
                    sb.Append(" - failed with ProtocolError");
                    Debug.WriteLine(sb.ToString());
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(" - Exception: {0}" + ex.Message);
                throw;
            }
        }
Esempio n. 22
0
        /// <summary>
        /// Creates new instance and adds to pool
        /// </summary>
        protected virtual PoolServiceDescriptor <TService> CreateNew(IContainerScope scope, bool locked)
        {
            PoolServiceDescriptor <TService> descriptor = new PoolServiceDescriptor <TService>();

            descriptor.Locked         = locked;
            descriptor.Scope          = scope;
            descriptor.LockExpiration = DateTime.UtcNow.Add(Options.MaximumLockDuration);
            if (Options.IdleTimeout > TimeSpan.Zero)
            {
                descriptor.IdleTimeout = DateTime.UtcNow + Options.IdleTimeout;
            }
            else
            {
                descriptor.IdleTimeout = null;
            }

            object instance = Descriptor.CreateInstance((TwinoServiceProvider)Container.GetProvider(), scope);

            if (Type == ImplementationType.Scoped && scope != null)
            {
                //we couldn't find any created instance. create new.
                scope.PutItem(typeof(TService), instance);
                descriptor.Instance = (TService)instance;
            }
            else
            {
                descriptor.Instance = (TService)instance;
            }

            if (_func != null)
            {
                _func(descriptor.Instance);
            }

            lock (Descriptors)
                Descriptors.Add(descriptor);

            return(descriptor);
        }
Esempio n. 23
0
        /// <summary>
        ///     generates container manifest of given type
        /// </summary>
        /// <param name="type"> </param>
        public ManifestClassDefinition(Type type, object[] predesc = null)
        {
            // we use indirect attribute usage to avoid msbuild context problems - we have to make compoents even in different versions of system
            Type    = type;
            predesc = predesc ??
                      type.GetCustomAttributes(true).Where(x =>
            {
                var baseType = x.GetType().BaseType;
                return(baseType != null && (x.GetType().Name == typeof(ContainerComponentAttribute).Name
                                            ||
                                            baseType.Name == typeof(ContainerComponentAttribute).Name));
            }).ToArray();

            foreach (var p in predesc)
            {
                var d = new ContainerComponentAttribute
                {
                    Lifestyle    = p.GetValue <Lifestyle>("Lifestyle"),
                    Name         = p.GetValue <string>("Name"),
                    Help         = p.GetValue <string>("Help"),
                    Role         = p.GetValue <string>("Role"),
                    ServiceType  = p.GetValue <Type>("ServiceType"),
                    Priority     = p.GetValue <int>("Priority"),
                    Tag          = p.GetValue <string>("Tag"),
                    Names        = p.GetValue <string[]>("Names"),
                    ServiceTypes = p.GetValue <Type[]>("ServiceTypes")
                };
                if (null == d.ServiceType && null == d.ServiceTypes)
                {
                    d.ServiceType =
                        type.GetInterfaces()
                        .Except(type.BaseType.GetInterfaces())
                        .FirstOrDefault(x => x != typeof(IContainerBound)) ??
                        type;
                }
                Descriptors.Add(d);
            }
        }
Esempio n. 24
0
        public void Consume(IMultipleResults resultSets)
        {
            IEnumerable <QueryMapMultiDepthResult> resultSet = resultSets.GetResult <QueryMapMultiDepthResult>();

            while (resultSet != null)
            {
                foreach (var queryMapResult in resultSet)
                {
                    if (queryMapResult.Level != null)
                    {
                        if (queryMapResult.NodeUid.HasValue && queryMapResult.NodeUid != Guid.Empty)
                        {
                            /// The QueryMap procedure returns ALL nodes by following relationships to max depth meaning some nodes are repeated in some of the levels multiple nodes may connect to them.
                            if (!Nodes.ContainsKey(queryMapResult.NodeUid.Value))
                            {
                                /// TODO: Need to consider copying the NodeOriginalId.
                                QueryMapNode node = new QueryMapNode();
                                node.NodeUid     = queryMapResult.NodeUid.Value;
                                node.DomainUid   = queryMapResult.DomainUid.Value;
                                node.NodeTypeUid = queryMapResult.NodeTypeUid;

                                Nodes[queryMapResult.NodeUid.Value] = node;
                            }
                        }
                    }
                    else if (queryMapResult.MetadataId != null)
                    {
                        if (queryMapResult.MetadataId.HasValue && queryMapResult.MetadataId != Guid.Empty)
                        {
                            QueryMapMetadata metadatum = new QueryMapMetadata();
                            metadatum.MetadataId        = queryMapResult.MetadataId.Value;
                            metadatum.NodeUid           = queryMapResult.NodeUid;
                            metadatum.RelationshipUid   = queryMapResult.RelationshipUid;
                            metadatum.DescriptorTypeUid = queryMapResult.DescriptorTypeUid;
                            metadatum.MetadataTypeUid   = queryMapResult.MetadataTypeUid;
                            metadatum.MetadataName      = queryMapResult.MetadataName;
                            metadatum.MetadataValue     = queryMapResult.MetadataValue;

                            Metadata.Add(metadatum);
                        }
                    }
                    else if (queryMapResult.DescriptorUid != null)
                    {
                        if (queryMapResult.DescriptorUid.HasValue && queryMapResult.DescriptorUid != Guid.Empty)
                        {
                            QueryMapDescriptor descriptor = new QueryMapDescriptor();
                            descriptor.DescriptorUid     = queryMapResult.DescriptorUid.Value;
                            descriptor.NodeUid           = queryMapResult.NodeUid;
                            descriptor.RelationshipUid   = queryMapResult.RelationshipUid;
                            descriptor.DescriptorTypeUid = queryMapResult.DescriptorTypeUid;

                            Descriptors.Add(descriptor);
                        }
                    }
                    else
                    {
                        if (queryMapResult.RelationshipUid.HasValue && queryMapResult.RelationshipUid != Guid.Empty)
                        {
                            /// TODO: Need to consider copying the RelationshipOriginalId.
                            QueryMapRelationship relationship = new QueryMapRelationship();
                            relationship.RelationshipUid     = queryMapResult.RelationshipUid.Value;
                            relationship.DomainUid           = queryMapResult.DomainUid.Value;
                            relationship.RelationshipTypeUid = queryMapResult.RelationshipTypeUid;

                            Relationships[relationship.RelationshipUid] = relationship;
                        }
                    }
                }

                resultSet = resultSets.GetResult <QueryMapMultiDepthResult>();
            }
        }
Esempio n. 25
0
 public void AddDescriptor(Descriptor descriptor)
 {
     Descriptors.Add(descriptor.DescriptorUid, descriptor);
 }
Esempio n. 26
0
        public QueryMapResultSet(IMultipleResults queryMapResultSets)
        {
            var queryMapResultSet = queryMapResultSets.GetResult <QueryMapMultiDepthResult>();

            while (queryMapResultSet != null)
            {
                foreach (var queryMapResult in queryMapResultSet)
                {
                    if (queryMapResult.Level != null)
                    {
                        if (queryMapResult.NodeUid.HasValue && queryMapResult.NodeUid != Guid.Empty)
                        {
                            /// Make sure that we aren't displaying a domain node.
                            if (queryMapResult.NodeTypeUid.HasValue && queryMapResult.NodeTypeUid != new Guid("263754C2-2F31-4D21-B9C4-6509E00A5E94"))
                            {
                                /// The QueryMap procedure returns ALL nodes by following relationships to max depth meaning some nodes are repeated in some of the levels multiple nodes may connect to them.
                                if (!Nodes.ContainsKey(queryMapResult.NodeUid.Value))
                                {
                                    /// TODO: Need to consider if we require the NodeOriginalId.
                                    QueryMapNode node = new QueryMapNode(queryMapResult);

                                    Nodes[queryMapResult.NodeUid.Value] = node;
                                }
                            }
                        }
                    }
                    else if (queryMapResult.MetadataId != null)
                    {
                        if (queryMapResult.MetadataId.HasValue && queryMapResult.MetadataId != Guid.Empty)
                        {
                            QueryMapMetadata metadatum = new QueryMapMetadata(queryMapResult);

                            if (metadatum.NodeUid.HasValue)
                            {
                                if (Nodes.ContainsKey(metadatum.NodeUid.Value))
                                {
                                    Nodes[metadatum.NodeUid.Value].AddMetadata(metadatum);
                                }
                            }

                            Metadata.Add(metadatum);
                        }
                    }
                    else if (queryMapResult.DescriptorUid != null)
                    {
                        if (queryMapResult.DescriptorUid.HasValue && queryMapResult.DescriptorUid != Guid.Empty)
                        {
                            QueryMapDescriptor descriptor = new QueryMapDescriptor(queryMapResult);

                            Descriptors.Add(descriptor);
                            AddDescriptorByNode(descriptor);
                            AddDescriptorByRelationship(descriptor);
                        }
                    }
                    else
                    {
                        if (queryMapResult.RelationshipUid.HasValue && queryMapResult.RelationshipUid != Guid.Empty)
                        {
                            /// TODO: Need to consider if we require the RelationshipOriginalId.
                            QueryMapRelationship relationship = new QueryMapRelationship(queryMapResult);

                            Relationships[relationship.RelationshipUid] = relationship;
                        }
                    }
                }

                queryMapResultSet = queryMapResultSets.GetResult <QueryMapMultiDepthResult>();
            }
        }
Esempio n. 27
0
 /// <summary>
 /// Use to add a single token expressing syntax highlighting.
 /// </summary>
 /// <param name="descriptorRecognition">Enum of DescriptorRecognition</param>
 /// <param name="token">The open token.</param>
 /// <param name="highlightType">Enum of HighlightType</param>s
 /// <param name="color">The color to highlight.</param>
 /// <param name="font">The font to highlight.</param>
 public void AddHighlightDescriptor(DescriptorRecognition descriptorRecognition, string token, HighlightType highlightType,
                                    Color color, Font font, UsedForAutoComplete used)
 {
     Descriptors.Add(new HighlightDescriptor(token, color, font, highlightType, descriptorRecognition, used));
 }
Esempio n. 28
0
 public Item()
 {
     Descriptors.Add(Descriptor.Item);
 }
Esempio n. 29
0
        private void PreprocessStructures()
        {
            bool changed = true;

            while (changed)
            {
                changed = false;
                foreach (SetDescriptor setDescriptor in Descriptors.Where(a => a.Field.IsStructure).ToArray())
                {
                    var memberInit = setDescriptor.Expression as MemberInitExpression;
                    if (memberInit != null)
                    {
                        changed = true;
                        Descriptors.Remove(setDescriptor);
                        foreach (MemberAssignment binding in memberInit.Bindings)
                        {
                            FieldInfo f = setDescriptor.Field.Fields.First(a => a.UnderlyingProperty == binding.Member);
                            Descriptors.Add(new SetDescriptor(f, setDescriptor.Parameter, binding.Expression));
                        }
                    }
                    else
                    {
                        foreach (FieldInfo f in setDescriptor.Field.Fields.Where(a => !a.IsStructure))
                        {
                            changed = true;
                            string name = f.Name;
                            if (setDescriptor.Field.IsStructure)
                            {
                                name = name.Remove(0, setDescriptor.Field.Name.Length + 1);
                            }
                            Descriptors.Remove(setDescriptor);
                            Expression ex   = setDescriptor.Expression;
                            var        call = ex as MethodCallExpression;
                            if (call != null && call.Method.DeclaringType == typeof(Queryable) &&
                                call.Method.Name.In("First", "FirstOrDefault", "Single", "SingleOrDefault"))
                            {
                                throw new NotSupportedException("Subqueries with structures are not supported");
                            }

                            /*ex = call.Arguments[0];
                             * ParameterExpression parameter = Expression.Parameter(setDescriptor.Expression.Type, "parameter");
                             * var list = new List<Model.FieldInfo> {f};
                             * while (list.Last().Parent != setDescriptor.Field)
                             * list.Add(f.Parent);
                             * list.Reverse();
                             * Expression member = parameter;
                             * foreach (Model.FieldInfo f2 in list)
                             * member = Expression.MakeMemberAccess(member, f2.UnderlyingProperty);
                             * LambdaExpression lambda =
                             * Expression.Lambda(
                             * typeof (Func<,>).MakeGenericType(parameter.Type, f.ValueType), member, parameter);
                             * ex = Expression.Call(
                             * typeof (Queryable), "Select", new[] {parameter.Type, f.ValueType}, ex, lambda);
                             * ex = Expression.Call(typeof (Queryable), call.Method.Name, new[] {f.ValueType}, ex);*/
                            else
                            {
                                //ex = Expression.Convert(ex, typeof(Structure));
                                var list = new List <FieldInfo> {
                                    f
                                };
                                while (list.Last().Parent != setDescriptor.Field)
                                {
                                    list.Add(f.Parent);
                                }
                                list.Reverse();
                                Expression member = ex;
                                foreach (FieldInfo f2 in list)
                                {
                                    member = Expression.MakeMemberAccess(member, f2.UnderlyingProperty);
                                }
                                ex = member;
                            }
                            Descriptors.Add(new SetDescriptor(f, setDescriptor.Parameter, ex));
                        }
                    }
                }
            }
        }