Exemplo n.º 1
0
 public ObjectContent(object value, ITypeDescriptor descriptor, bool isPrimitive, IReference reference)
     : base(descriptor, isPrimitive, reference)
 {
     if (reference is ObjectReference)
         throw new ArgumentException($"An {nameof(ObjectContent)} cannot contain an {nameof(ObjectReference)}");
     this.value = value;
 }
    public IDeclaredElement GetPrimaryDeclaredElement(IDeclaredElement declaredElement, IReference reference)
    {
      IDeclaredElement derivedElement = null;

      var method = declaredElement as IMethod;
      if (method != null)
      {
        derivedElement = DerivedDeclaredElementUtil.GetPrimaryDeclaredElementForMethod(method);
      }


      var @class = declaredElement as IClass;
      if (@class != null)
        derivedElement = DerivedDeclaredElementUtil.GetPrimaryDeclaredElementForClass(@class);

      var @interface = declaredElement as IInterface;
      if (@interface != null)
        derivedElement = DerivedDeclaredElementUtil.GetPrimaryDeclaredElementForInterface(@interface);

      if(derivedElement != null)
      {
        return derivedElement;
      }
      return declaredElement;
    }
 public MethodInvocation(IReference reference, IType type, IMethod method, ISubstitution substitution)
 {
   Reference = reference;
   Type = type;
   Method = method;
   Substitution = substitution;
 }
Exemplo n.º 4
0
		public static bool ReinstallPackageOn(ILogger logger, IReference newPackage, string sourceDirectory, IEnumerable<string> installDirs)
		{
			foreach (string installDir in installDirs)
				if (!InstallPackage(logger, newPackage, installDir, sourceDirectory))
					return false;
			return true;
		}
 public virtual void PrintAttribute(IReference target, ICustomAttribute attribute, bool newLine, string targetType) {
   this.sourceEmitterOutput.Write("[", newLine);
   if (targetType != null) {
     this.sourceEmitterOutput.Write(targetType);
     this.sourceEmitterOutput.Write(": ");
   }
   this.PrintTypeReferenceName(attribute.Constructor.ContainingType);
   if (attribute.NumberOfNamedArguments > 0 || IteratorHelper.EnumerableIsNotEmpty(attribute.Arguments)) {
     this.sourceEmitterOutput.Write("(");
     bool first = true;
     foreach (var argument in attribute.Arguments) {
       if (first)
         first = false;
       else
         this.sourceEmitterOutput.Write(", ");
       this.Traverse(argument);
     }
     foreach (var namedArgument in attribute.NamedArguments) {
       if (first)
         first = false;
       else
         this.sourceEmitterOutput.Write(", ");
       this.Traverse(namedArgument);
     }
     this.sourceEmitterOutput.Write(")");
   }
   this.sourceEmitterOutput.Write("]");
   if (newLine) this.sourceEmitterOutput.WriteLine("");
 }
Exemplo n.º 6
0
        public static AssetLogMessage From(Package package, IReference assetReference, ILogMessage logMessage, string assetPath, int line = 0, int character = 0)
        {
            // Transform to AssetLogMessage
            var assetLogMessage = logMessage as AssetLogMessage;
            if (assetLogMessage == null)
            {
                assetLogMessage = new AssetLogMessage(null, assetReference, logMessage.Type, AssetMessageCode.CompilationMessage, assetReference?.Location, logMessage.Text)
                {
                    Exception = (logMessage as LogMessage)?.Exception
                };
            }

            // Set file (and location if available)
            assetLogMessage.File = assetPath;
            assetLogMessage.Line = line;
            assetLogMessage.Character = character;

            // Generate location (if it's a Yaml exception)
            var yamlException = (logMessage as LogMessage)?.Exception as YamlException;
            if (yamlException != null)
            {
                assetLogMessage.Line = yamlException.Start.Line;
                assetLogMessage.Character = yamlException.Start.Column;
                // We've already got everything, no need to pollute log with stack trace of exception
                assetLogMessage.Exception = null;
            }

            return assetLogMessage;
        }
        public IReference[] GetReferences(ITreeNode element, IReference[] oldReferences)
        {
            var literal = element as ILiteralExpression;
            if (literal != null && literal.ConstantValue.Value is string)
            {
                var attribute = AttributeNavigator.GetByConstructorArgumentExpression(literal as ICSharpExpression);
                if (attribute != null)
                {
                    var @class = attribute.Name.Reference.Resolve().DeclaredElement as IClass;
                    if (@class != null && Equals(@class.GetClrName(), DataAttributeName))
                    {
                        var typeElement = (from a in attribute.PropertyAssignments
                                           where a.PropertyNameIdentifier.Name == TypeMemberName
                                           select GetTypeof(a.Source as ITypeofExpression)).FirstOrDefault();

                        var member = MethodDeclarationNavigator.GetByAttribute(attribute);
                        if (member != null && member.DeclaredElement != null && typeElement == null)
                            typeElement = member.DeclaredElement.GetContainingType();

                        if (typeElement == null)
                            return EmptyArray<IReference>.Instance;

                        var reference = CreateReference(typeElement, literal);

                        return oldReferences != null && oldReferences.Length == 1 && Equals(oldReferences[0], reference)
                                   ? oldReferences
                                   : new[] {reference};
                    }
                }
            }

            return EmptyArray<IReference>.Instance;
        }
        public IReference[] GetReferences(ITreeNode element, IReference[] oldReferences)
        {
            var literal = element as ILiteralExpression;
            if (literal != null && literal.ConstantValue.Value is string)
            {
                var agument = literal.Parent as IVBArgument;
                var attribute = AttributeNavigator.GetByArgument(agument);
                if (attribute != null)
                {
                    var @class = attribute.AttributeType.Reference.Resolve().DeclaredElement as IClass;
                    if (@class != null && Equals(@class.GetClrName(), DataAttributeName))
                    {
                        var typeElement = (from a in attribute.Arguments
                                           where a is INamedArgument && a.ArgumentName == TypeMemberName
                                           select GetTypeof(a.Expression as IGetTypeExpression)).FirstOrDefault();

                        var member = MethodDeclarationNavigator.GetByAttribute(attribute) as ITypeMemberDeclaration;
                        if (member != null && member.DeclaredElement != null && typeElement == null)
                            typeElement = member.DeclaredElement.GetContainingType();

                        if (typeElement == null)
                            return EmptyArray<IReference>.Instance;

                        var reference = CreateReference(typeElement, literal);

                        return oldReferences != null && oldReferences.Length == 1 && Equals(oldReferences[0], reference)
                                   ? oldReferences
                                   : new[] { reference };
                    }
                }
            }

            return EmptyArray<IReference>.Instance;
        }
Exemplo n.º 9
0
 protected ContentBase(ITypeDescriptor descriptor, bool isPrimitive, IReference reference)
 {
     if (descriptor == null) throw new ArgumentNullException(nameof(descriptor));
     Reference = reference;
     Descriptor = descriptor;
     IsPrimitive = isPrimitive;
 }
    public PsiUnresolvedVariableReferenceHighlighting(IVariableName element)
    {
      myElement = element;

      myReference = (element as VariableName).Reference;

    }
Exemplo n.º 11
0
        protected override bool CheckResolve(IReference reference, IElement element)
        {
            if (reference is TableReference && !DatabaseManager.GetInstance(element.GetManager().Solution).Enabled)
                return false;

            return base.CheckResolve(reference, element);
        }
Exemplo n.º 12
0
        public void VisitMethodBodyReference(IReference reference)
        {
            var typeReference = reference as ITypeReference;
            if (typeReference != null)
            {
                this.typeReferenceNeedsToken = true;
                this.Visit(typeReference);
                Debug.Assert(!this.typeReferenceNeedsToken);
            }
            else
            {
                var fieldReference = reference as IFieldReference;
                if (fieldReference != null)
                {
                    if (fieldReference.IsContextualNamedEntity)
                    {
                        ((IContextualNamedEntity)fieldReference).AssociateWithMetadataWriter(this.metadataWriter);
                    }

                    this.Visit(fieldReference);
                }
                else
                {
                    var methodReference = reference as IMethodReference;
                    if (methodReference != null)
                    {
                        this.Visit(methodReference);
                    }
                }
            }
        }
    public PsiUnresolvedPathReferenceHighlighting(IPathName element)
    {
      myElement = element;

      myReference = (element as PathName).Reference;

    }
			public DeclaredElementInfo([NotNull] IDeclaredElement declaredElement, [NotNull] ISubstitution substitution, [NotNull] IFile file,
				TextRange sourceRange, [CanBeNull] IReference reference) {
				DeclaredElement = declaredElement;
				Substitution = substitution;
				File = file;
				SourceRange = sourceRange;
				Reference = reference;
			}
Exemplo n.º 15
0
 public AssetLogger(Package package, IReference assetReference, string assetFullPath, ILogger loggerToForward)
 {
     this.package = package;
     this.assetReference = assetReference;
     this.assetFullPath = assetFullPath;
     this.loggerToForward = loggerToForward;
     ActivateLog(LogMessageType.Debug);
 }
Exemplo n.º 16
0
 public StorageManager(IReference storage)
 {
     var g=CodeGenerator.Instance;
       var f=FuncBuilder.Instance;
       //don't use statics for storage
       this.storage=g.GetStaticVariableInfo(storage, false)!=null ? f.Declare.Int("temp2") : storage;
       this.temp=f.Declare.Int("temp");
 }
Exemplo n.º 17
0
 public bool Equals(IReference obj)
 {
     if (obj == null) return false;
     if (obj == this) return true;
     var fr = obj as FileReference;
     if (fr != null) return fr.Filename == this.Filename;
     return false;
 }
 /// <summary>
 /// Initializes a new instance of <see cref="AssetMigrationContext"/>.
 /// </summary>
 /// <param name="package"></param>
 /// <param name="assetReference"></param>
 /// <param name="assetFullPath"></param>
 /// <param name="log"></param>
 public AssetMigrationContext(Package package, IReference assetReference, string assetFullPath, ILogger log)
 {
     if (log == null) throw new ArgumentNullException(nameof(log));
     Package = package;
     AssetReference = assetReference;
     AssetFullPath = assetFullPath;
     Log = new AssetLogger(package, assetReference, assetFullPath, log);
 }
Exemplo n.º 19
0
 protected virtual IReference DeclareHelper(string name, IReference variable, Expression optionalInitialValue)
 {
     FuncBuilder.Instance.BindLocalVariableToRepresentation(variable, name);
       if(!ReferenceEquals(optionalInitialValue, null)) {
     Assignment.AssignAny(variable, optionalInitialValue);
       }
       return variable;
 }
Exemplo n.º 20
0
        public void AddReference(IReference reference)
        {
            var assembly = reference.GetAssembly();

            references.Add(assembly);

            compiler.Parameters.AddAssembly(assembly);
        }
Exemplo n.º 21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AssetLogMessage" /> class.
 /// </summary>
 /// <param name="package">The package.</param>
 /// <param name="assetReference">The asset reference.</param>
 /// <param name="type">The type.</param>
 /// <param name="messageCode">The message code.</param>
 /// <param name="arguments">The arguments.</param>
 /// <exception cref="System.ArgumentNullException">asset</exception>
 public AssetLogMessage(Package package, IReference assetReference, LogMessageType type, string text)
 {
     this.package = package;
     AssetReference = assetReference;
     Type = type;
     Related = new List<IReference>();
     Text = text;
 }
 public static Mock<IVsProject> ConstructMockProject(IReference[] references = null, string outputAssembly = null)
 {
     var project = new Mock<IVsProject>();
     project.Setup(proj => proj.GetBinaryReferences()).Returns(references ?? new IReference[0]);
     outputAssembly = outputAssembly ?? "randomAssemblyName" + Path.GetTempFileName();
     project.SetupGet(p => p.AssemblyName).Returns(outputAssembly);
     return project;
 }
Exemplo n.º 23
0
        /// <summary>
        /// Create an asset dependency of type <paramref name="type"/> and pointing to <paramref name="item"/>
        /// </summary>
        /// <param name="item">The item the dependency is pointing to</param>
        /// <param name="type">The type of the dependency between the items</param>
        public AssetLink(AssetItem item, ContentLinkType type)
        {
            if (item == null) throw new ArgumentNullException("item");

            Item = item;
            this.type = type;
            reference = item.ToReference();
        }
Exemplo n.º 24
0
        // This constructor exists for better factorization of code in AssetDependencies. 
        // It should not be turned into public as AssetItem is not valid.
        internal AssetLink(IReference reference, ContentLinkType type)
        {
            if (reference == null) throw new ArgumentNullException("reference");

            Item = null;
            this.type = type;
            this.reference = reference;
        }
Exemplo n.º 25
0
 public bool Equals(IReference obj)
 {
     if (obj == null) return false;
     if (obj == this) return true;
     var fr = obj as ProjectReference;
     if (fr != null) return fr.Name == this.Name;
     return false;
 }
Exemplo n.º 26
0
 public MemberContent(INodeBuilder nodeBuilder, IContent container, IMemberDescriptor member, bool isPrimitive, IReference reference)
     : base(nodeBuilder.TypeDescriptorFactory.Find(member.Type), isPrimitive, reference)
 {
     if (container == null) throw new ArgumentNullException(nameof(container));
     Member = member;
     Container = container;
     nodeContainer = nodeBuilder.NodeContainer;
 }
Exemplo n.º 27
0
 public static AddressOf FromStaticVariable(IReference variable)
 {
     var vi=CodeGenerator.Instance.GetStaticVariableInfo(variable, false);
       if(vi==null) {
     throw new Exception("Can't take the address of a non-static variable");
       }
       var rep=vi.Representation;
       return new AddressOf(rep.StorageLabel, false);
 }
Exemplo n.º 28
0
 public override ReferenceCollection GetFirstClassReferences()
 {
   if (!myInitReference)
   {
     myReference = new PsiOptionReference(this);
     myInitReference = true;
   }
   return new ReferenceCollection(myReference);
 }
Exemplo n.º 29
0
 public IReadable EvaluateTo(IReference storage)
 {
     var result=EvaluateToHelper(storage);
       var reference=result as IReference;
       if(reference!=null) {
     FuncBuilder.Instance.NoteRead(reference);
       }
       return result;
 }
Exemplo n.º 30
0
 public ResolveResultWithInfo Resolve()
 {
   if (!myInitReference)
   {
     myReference = new PsiVariableReference(this);
     myInitReference = true;
   }
   return myReference.Resolve();
 }
Exemplo n.º 31
0
 public MemberReference(IReference parentFieldCollection, MemberInfo memberInfo)
 {
     this.parentReference = parentFieldCollection;
     this.parentValue     = parentFieldCollection.GetValue();
     this.memberInfo      = memberInfo;
 }
Exemplo n.º 32
0
        /// <summary>
        /// Adds a node to the set.
        /// </summary>
        public void Export(ISystemContext context, NodeState node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            if (Opc.Ua.NodeId.IsNull(node.NodeId))
            {
                throw new ArgumentException("A non-null NodeId must be specified.");
            }

            UANode exportedNode = null;

            switch (node.NodeClass)
            {
            case NodeClass.Object:
            {
                BaseObjectState o     = (BaseObjectState)node;
                UAObject        value = new UAObject();
                value.EventNotifier = o.EventNotifier;

                if (o.Parent != null)
                {
                    value.ParentNodeId = ExportAlias(o.Parent.NodeId, context.NamespaceUris);
                }

                exportedNode = value;
                break;
            }

            case NodeClass.Variable:
            {
                BaseVariableState o     = (BaseVariableState)node;
                UAVariable        value = new UAVariable();
                value.DataType                = ExportAlias(o.DataType, context.NamespaceUris);
                value.ValueRank               = o.ValueRank;
                value.ArrayDimensions         = Export(o.ArrayDimensions);
                value.AccessLevel             = o.AccessLevel;
                value.UserAccessLevel         = o.UserAccessLevel;
                value.MinimumSamplingInterval = o.MinimumSamplingInterval;
                value.Historizing             = o.Historizing;

                if (o.Parent != null)
                {
                    value.ParentNodeId = ExportAlias(o.Parent.NodeId, context.NamespaceUris);
                }

                if (o.Value != null)
                {
                    XmlEncoder encoder = CreateEncoder(context);

                    Variant variant = new Variant(o.Value);
                    encoder.WriteVariantContents(variant.Value, variant.TypeInfo);

                    XmlDocument document = new XmlDocument();
                    document.InnerXml = encoder.Close();
                    value.Value       = document.DocumentElement;
                }

                exportedNode = value;
                break;
            }

            case NodeClass.Method:
            {
                MethodState o     = (MethodState)node;
                UAMethod    value = new UAMethod();
                value.Executable     = o.Executable;
                value.UserExecutable = o.UserExecutable;

                if (o.TypeDefinitionId != o.NodeId)
                {
                    value.MethodDeclarationId = Export(o.TypeDefinitionId, context.NamespaceUris);
                }

                if (o.Parent != null)
                {
                    value.ParentNodeId = ExportAlias(o.Parent.NodeId, context.NamespaceUris);
                }

                exportedNode = value;
                break;
            }

            case NodeClass.View:
            {
                ViewState o     = (ViewState)node;
                UAView    value = new UAView();
                value.ContainsNoLoops = o.ContainsNoLoops;
                exportedNode          = value;
                break;
            }

            case NodeClass.ObjectType:
            {
                BaseObjectTypeState o     = (BaseObjectTypeState)node;
                UAObjectType        value = new UAObjectType();
                value.IsAbstract = o.IsAbstract;
                exportedNode     = value;
                break;
            }

            case NodeClass.VariableType:
            {
                BaseVariableTypeState o     = (BaseVariableTypeState)node;
                UAVariableType        value = new UAVariableType();
                value.IsAbstract      = o.IsAbstract;
                value.DataType        = ExportAlias(o.DataType, context.NamespaceUris);
                value.ValueRank       = o.ValueRank;
                value.ArrayDimensions = Export(o.ArrayDimensions);

                if (o.Value != null)
                {
                    XmlEncoder encoder = CreateEncoder(context);

                    Variant variant = new Variant(o.Value);
                    encoder.WriteVariantContents(variant.Value, variant.TypeInfo);

                    XmlDocument document = new XmlDocument();
                    document.InnerXml = encoder.Close();
                    value.Value       = document.DocumentElement;
                }

                exportedNode = value;
                break;
            }

            case NodeClass.DataType:
            {
                DataTypeState o     = (DataTypeState)node;
                UADataType    value = new UADataType();
                value.IsAbstract = o.IsAbstract;
                value.Definition = Export(o.Definition, context.NamespaceUris);
                exportedNode     = value;
                break;
            }

            case NodeClass.ReferenceType:
            {
                ReferenceTypeState o     = (ReferenceTypeState)node;
                UAReferenceType    value = new UAReferenceType();
                value.IsAbstract  = o.IsAbstract;
                value.InverseName = Export(new Opc.Ua.LocalizedText[] { o.InverseName });
                value.Symmetric   = o.Symmetric;
                exportedNode      = value;
                break;
            }
            }

            exportedNode.NodeId        = Export(node.NodeId, context.NamespaceUris);
            exportedNode.BrowseName    = Export(node.BrowseName, context.NamespaceUris);
            exportedNode.DisplayName   = Export(new Opc.Ua.LocalizedText[] { node.DisplayName });
            exportedNode.Description   = Export(new Opc.Ua.LocalizedText[] { node.Description });
            exportedNode.WriteMask     = (uint)node.WriteMask;
            exportedNode.UserWriteMask = (uint)node.UserWriteMask;

            if (!String.IsNullOrEmpty(node.SymbolicName) && node.SymbolicName != node.BrowseName.Name)
            {
                exportedNode.SymbolicName = node.SymbolicName;
            }

            // export references.
            INodeBrowser     browser            = node.CreateBrowser(context, null, null, true, BrowseDirection.Both, null, null, true);
            List <Reference> exportedReferences = new List <Reference>();
            IReference       reference          = browser.Next();

            while (reference != null)
            {
                if (node.NodeClass == NodeClass.Method)
                {
                    if (!reference.IsInverse && reference.ReferenceTypeId == ReferenceTypeIds.HasTypeDefinition)
                    {
                        reference = browser.Next();
                        continue;
                    }
                }

                Reference exportedReference = new Reference();

                exportedReference.ReferenceType = ExportAlias(reference.ReferenceTypeId, context.NamespaceUris);
                exportedReference.IsForward     = !reference.IsInverse;
                exportedReference.Value         = Export(reference.TargetId, context.NamespaceUris, context.ServerUris);
                exportedReferences.Add(exportedReference);

                reference = browser.Next();
            }

            exportedNode.References = exportedReferences.ToArray();

            // add node to list.
            UANode[] nodes = null;

            int count = 1;

            if (this.Items == null)
            {
                nodes = new UANode[count];
            }
            else
            {
                count += this.Items.Length;
                nodes  = new UANode[count];
                Array.Copy(this.Items, nodes, this.Items.Length);
            }

            nodes[count - 1] = exportedNode;

            this.Items = nodes;

            // recusively process children.
            List <BaseInstanceState> children = new List <BaseInstanceState>();

            node.GetChildren(context, children);

            for (int ii = 0; ii < children.Count; ii++)
            {
                Export(context, children[ii]);
            }
        }
Exemplo n.º 33
0
 /// <summary cref="ICollection{T}.Add" />
 public void Add(IReference item)
 {
     m_references.Add(item, null);
 }
Exemplo n.º 34
0
 /// <summary>
 /// Adds a broken link out.
 /// </summary>
 /// <param name="reference">the reference to the missing element</param>
 /// <param name="contentLinkType">The type of link</param>
 /// <exception cref="ArgumentException">A broken link to this element already exists</exception>
 public void AddBrokenLinkOut(IReference reference, ContentLinkType contentLinkType)
 {
     AddLink(ref missingChildren, new AssetLink(reference, contentLinkType));
 }
Exemplo n.º 35
0
 public CacheReference(IReference <T> entry, Cache <T> cache)
 {
     _entry = entry;
     _cache = cache;
 }
Exemplo n.º 36
0
 protected override IReadable EvaluateToHelper(IReference storage)
 {
     return(inner.EvaluateTo(storage));
 }
Exemplo n.º 37
0
 /// <summary>
 ///   Initializes a new instance of the <see cref = "CreateOnUIThreadInspector" /> class.
 /// </summary>
 /// <param name = "config">The config.</param>
 /// <param name = "converter"></param>
 public CreateOnUIThreadInspector(IConfiguration config, IConversionManager converter)
 {
     marshalingControl = new MarshalingControl();
     controlProxyHook  = ObtainProxyHook(config, converter);
 }
Exemplo n.º 38
0
        public IDeclaredElement GetPrimaryDeclaredElement(IDeclaredElement declaredElement, IReference reference)
        {
            IDeclaredElement derivedElement = null;

            var method = declaredElement as IMethod;

            if (method != null)
            {
                derivedElement = DerivedDeclaredElementUtil.GetPrimaryDeclaredElementForMethod(method);
            }


            var @class = declaredElement as IClass;

            if (@class != null)
            {
                derivedElement = DerivedDeclaredElementUtil.GetPrimaryDeclaredElementForClass(@class);
            }

            var @interface = declaredElement as IInterface;

            if (@interface != null)
            {
                derivedElement = DerivedDeclaredElementUtil.GetPrimaryDeclaredElementForInterface(@interface);
            }

            if (derivedElement != null)
            {
                return(derivedElement);
            }
            return(declaredElement);
        }
        /// <summary>
        /// Creates view model for Editing factor data ie EditFactorItem.ascx
        /// </summary>
        /// <param name="user"></param>
        /// <param name="taxon"></param>
        /// <param name="factorData"></param>
        /// <param name="factorDataType"></param>
        /// <param name="model"></param>
        /// <returns></returns>
        public FactorViewModel CreateFactorViewData(IUserContext user, ITaxon taxon, DyntaxaSpeciesFact factorData, int factorDataType, int dataTypeId, FactorViewModel model, IList <DyntaxaIndividualCategory> allIndividualCategories, string referenceId, bool isHost)
        {
            model.FactorDataTypeId = factorDataType;
            model.DataTypeId       = dataTypeId;
            model.FactorName       = factorData.Label;
            if (isHost)
            {
                model.FactorName = factorData.HostName;
            }

            model.IndividualCategoryName = factorData.IndividualCatgory.Label;
            model.QualityId        = factorData.Quality.QualityId;
            model.QualityValueList = new List <SpeciesFactDropDownModelHelper>();
            foreach (KeyValuePair <int, string> quality in factorData.Quality.Qualities)
            {
                model.QualityValueList.Add(new SpeciesFactDropDownModelHelper(quality.Key, quality.Value));
            }

            model.FactorFieldComment       = factorData.Comments;
            model.FactorFieldEnumLabel     = factorData.FactorEnumLabel;
            model.FactorFieldEnumValueList = new List <SpeciesFactDropDownModelHelper>();
            foreach (KeyValuePair <int, string> factorFieldEnum in factorData.FactorEnumValueList)
            {
                // Only add 0 and positiv values for Substrate and Biotope.
                if ((factorFieldEnum.Key >= 0 && factorDataType == (int)DyntaxaFactorDataType.AF_BIOTOPE) ||
                    (factorFieldEnum.Key >= 0 && factorDataType == (int)DyntaxaFactorDataType.AF_SUBSTRATE) ||
                    factorDataType == (int)DyntaxaFactorDataType.AF_INFLUENCE)
                {
                    model.FactorFieldEnumValueList.Add(new SpeciesFactDropDownModelHelper(factorFieldEnum.Key, factorFieldEnum.Value));
                }
            }

            model.FactorFieldEnumValue      = factorData.FactorEnumValue;
            model.FactorFieldEnumValueList2 = new List <SpeciesFactDropDownModelHelper>();
            foreach (KeyValuePair <int, string> factorFieldEnum2 in factorData.FactorEnumValueList2)
            {
                // Only add 0 and positiv values for Substrate and Biotope.
                if (factorDataType == (int)DyntaxaFactorDataType.AF_SUBSTRATE || factorDataType == (int)DyntaxaFactorDataType.AF_INFLUENCE)
                {
                    model.FactorFieldEnumValueList2.Add(new SpeciesFactDropDownModelHelper(factorFieldEnum2.Key, factorFieldEnum2.Value));
                }
            }

            model.FactorFieldEnumValueList2.Add(new SpeciesFactDropDownModelHelper(SpeciesFactModelManager.SpeciesFactNoValueSet, DyntaxaResource.SpeciesFactNoValueSet));
            model.FactorFieldEnumValue2 = factorData.FactorEnumValue2;
            model.FactorFieldEnumLabel2 = factorData.FactorEnumLabel2;
            model.FaktorReferenceList   = new List <SpeciesFactDropDownModelHelper>();
            bool isReferenceSet     = false;
            int  dyntaxaReferenceId = 0;
            int  userReferenceId    = 0;

            if (referenceId.IsNotEmpty())
            {
                isReferenceSet = true;

                var referenceList = ReferenceHelper.GetReferenceList(user);
                foreach (IReference reference in referenceList)
                {
                    if (reference.Id == Convert.ToInt32(referenceId))
                    {
                        model.FaktorReferenceList.Add(new SpeciesFactDropDownModelHelper(reference.Id, reference.Name + " " + reference.Year));
                        userReferenceId         = reference.Id;
                        model.FactorReferenceId = reference.Id;
                    }
                }

                if (factorData.ReferenceName.IsNotEmpty())
                {
                    model.FactorReferenceOld = factorData.ReferenceName;
                }
                else
                {
                    model.FactorReferenceOld = "-";
                }
            }

            if (factorData.DyntaxaFactorReference.IsNotNull())
            {
                if (!isReferenceSet)
                {
                    isReferenceSet          = true;
                    model.FactorReferenceId = factorData.DyntaxaFactorReference.GetReference(user).Id;
                }

                dyntaxaReferenceId = factorData.DyntaxaFactorReference.GetReference(user).Id;
                IReference reference = factorData.DyntaxaFactorReference.GetReference(user);
                Int32      year      = reference.Year.HasValue ? reference.Year.Value : -1;
                model.FaktorReferenceList.Add(new SpeciesFactDropDownModelHelper(reference.Id, reference.Name + " " + year));
            }

            // Here we get the dyntaxa references...
            foreach (IReferenceRelation referenceRelation in taxon.GetReferenceRelations(user))
            {
                IReference reference = referenceRelation.GetReference(user);
                Int32      year      = reference.Year.HasValue ? reference.Year.Value : -1;
                if (reference.Id != dyntaxaReferenceId && reference.Id != userReferenceId)
                {
                    model.FaktorReferenceList.Add(
                        new SpeciesFactDropDownModelHelper(
                            reference.Id,
                            reference.Name + " " + year));
                }

                if (!isReferenceSet)
                {
                    isReferenceSet          = true;
                    model.FactorReferenceId = reference.Id;
                }
            }

            model.IndividualCategoryId   = factorData.IndividualCatgory.Id;
            model.IndividualCategoryName = factorData.IndividualCatgory.Label;
            model.IndividualCategoryList = new List <SpeciesFactDropDownModelHelper>();

            // Add all individual categories that exist
            List <DyntaxaIndividualCategory> exitingCategories = factorData.IndividualCategoryList as List <DyntaxaIndividualCategory>;

            foreach (DyntaxaIndividualCategory category in allIndividualCategories)
            {
                model.IndividualCategoryList.Add(new SpeciesFactDropDownModelHelper(category.Id, category.Label));
            }

            model.ExistingEvaluations = factorData.ExistingEvaluations;
            string message = Resources.DyntaxaResource.SpeciesFactLatestUpdateByText.Replace("[UpdateDate]", factorData.UpdateDate.ToShortDateString());

            message = message.Replace("[UpdateUserFullName]", factorData.UpdateUserFullName);
            model.UpdateUserData = message;

            return(model);
        }
Exemplo n.º 40
0
        /// <summary cref="IDictionary.Remove" />
        public bool Remove(IReference key)
        {
            // validate key.
            if (!ValidateReference(key, false))
            {
                return(false);
            }

            m_version++;

            // look up the reference type.
            ReferenceTypeEntry entry = null;

            if (!m_references.TryGetValue(key.ReferenceTypeId, out entry))
            {
                return(false);
            }

            // handle reference to external targets.
            if (key.TargetId.IsAbsolute)
            {
                Dictionary <ExpandedNodeId, LinkedListNode <KeyValuePair <IReference, T> > > targets = null;

                if (key.IsInverse)
                {
                    targets = entry.InverseExternalTargets;
                }
                else
                {
                    targets = entry.ForwardExternalTargets;
                }

                if (targets == null)
                {
                    return(false);
                }

                LinkedListNode <KeyValuePair <IReference, T> > node;

                if (!targets.TryGetValue(key.TargetId, out node))
                {
                    return(false);
                }

                m_list.Remove(node);
                targets.Remove(key.TargetId);
            }

            // handle reference to internal target.
            else
            {
                NodeIdDictionary <LinkedListNode <KeyValuePair <IReference, T> > > targets = null;

                if (key.IsInverse)
                {
                    targets = entry.InverseTargets;
                }
                else
                {
                    targets = entry.ForwardTargets;
                }

                if (targets == null)
                {
                    return(false);
                }

                LinkedListNode <KeyValuePair <IReference, T> > node;

                if (!targets.TryGetValue((NodeId)key.TargetId, out node))
                {
                    return(false);
                }

                m_list.Remove(node);
                targets.Remove((NodeId)key.TargetId);
            }

            // remove empty reference.
            if (entry.IsEmpty)
            {
                m_references.Remove(key.ReferenceTypeId);
            }

            return(true);
        }
Exemplo n.º 41
0
 /// <summary cref="IDictionary.Add" />
 public void Add(IReference key, T value)
 {
     Add(key, value, false);
 }
Exemplo n.º 42
0
        public static bool TryParse(string rootDirectory, string projFilePath, XElement element, out IReference reference)
        {
            reference = null;

            var projDirectory = Path.GetDirectoryName(projFilePath);
            var includeAttr   = element.Attribute("Include");

            if (projDirectory == null || includeAttr == null)
            {
                return(false);
            }

            var hintPathElement = element.Element(Constants.MsBuild + "HintPath");
            var hintPath        = hintPathElement == null
                ? null
                : Path.GetFullPath(Path.Combine(projDirectory, hintPathElement.Value));

            reference = new Reference <XElement>(rootDirectory, "", includeAttr.Value, hintPath, "", element, RelationTypes.Reference);

            return(true);
        }
Exemplo n.º 43
0
        /// <summary>
        /// Returns the target entry associated with the reference.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <param name="value">The value.</param>
        /// <returns>The target entry associated with the reference.</returns>
        private bool TryGetEntry(IReference key, out KeyValuePair <IReference, T> value)
        {
            value = new KeyValuePair <IReference, T>();

            // validate key.
            if (!ValidateReference(key, false))
            {
                return(false);
            }

            // look up the reference type.
            ReferenceTypeEntry entry = null;

            if (!m_references.TryGetValue(key.ReferenceTypeId, out entry))
            {
                return(false);
            }

            // handle reference to external targets.
            if (key.TargetId.IsAbsolute)
            {
                Dictionary <ExpandedNodeId, LinkedListNode <KeyValuePair <IReference, T> > > targets = null;

                if (key.IsInverse)
                {
                    targets = entry.InverseExternalTargets;
                }
                else
                {
                    targets = entry.ForwardExternalTargets;
                }

                if (targets == null)
                {
                    return(false);
                }

                LinkedListNode <KeyValuePair <IReference, T> > node;

                if (targets.TryGetValue(key.TargetId, out node))
                {
                    value = node.Value;
                    return(true);
                }
            }

            // handle reference to internal target.
            else
            {
                NodeIdDictionary <LinkedListNode <KeyValuePair <IReference, T> > > targets = null;

                if (key.IsInverse)
                {
                    targets = entry.InverseTargets;
                }
                else
                {
                    targets = entry.ForwardTargets;
                }

                if (targets == null)
                {
                    return(false);
                }

                LinkedListNode <KeyValuePair <IReference, T> > node;

                if (targets.TryGetValue((NodeId)key.TargetId, out node))
                {
                    value = node.Value;
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 44
0
        protected void HandleEnter(IReference reference, bool appear)
        {
            Exited = false;

            // StateHasChanged();
        }
Exemplo n.º 45
0
 public override bool HasConflictWith(IReference storage)
 {
     return(inner.HasConflictWith(storage));
 }
Exemplo n.º 46
0
        /// <inheritdoc/>
        public bool Equals(IReference other)
        {
            var otherEnumerable = other as ReferenceEnumerable;

            return(otherEnumerable != null && DesignExtensions.Equals <IReference>(references, otherEnumerable.references));
        }
Exemplo n.º 47
0
 public ICommentAspect Load(IReference reference)
 {
     return(_commentAspectMapper.Map(_commentRepository.FindById(reference.Code)));
 }
Exemplo n.º 48
0
 public ObjectContent(object value, ITypeDescriptor descriptor, bool isPrimitive, IReference reference)
     : base(descriptor, isPrimitive, reference)
 {
     if (reference is ObjectReference)
     {
         throw new ArgumentException($"An {nameof(ObjectContent)} cannot contain an {nameof(ObjectReference)}");
     }
     this.value = value;
 }
Exemplo n.º 49
0
 public ObjectNode([NotNull] INodeBuilder nodeBuilder, object value, Guid guid, [NotNull] ITypeDescriptor descriptor, IReference reference)
     : base(nodeBuilder.SafeArgument(nameof(nodeBuilder)).NodeContainer, guid, descriptor)
 {
     if (reference is ObjectReference)
     {
         throw new ArgumentException($"An {nameof(ObjectNode)} cannot contain an {nameof(ObjectReference)}");
     }
     this.value     = value;
     ItemReferences = reference as ReferenceEnumerable;
 }
Exemplo n.º 50
0
            protected override object Read(PushbackTextReader r, char caret, object opts)
            {
                int startLine = -1;
                int startCol  = -1;
                LineNumberingTextReader lntr = r as LineNumberingTextReader;

                if (lntr != null)
                {
                    startLine = lntr.LineNumber;
                    startCol  = lntr.ColumnNumber;
                }

                IPersistentMap metaAsMap;
                {
                    object meta = ReadAux(r, opts);

                    if (meta is Symbol || meta is String)
                    {
                        metaAsMap = RT.map(RT.TagKey, meta);
                    }
                    else if (meta is Keyword)
                    {
                        metaAsMap = RT.map(meta, true);
                    }
                    else if ((metaAsMap = meta as IPersistentMap) == null)
                    {
                        throw new ArgumentException("Metadata must be Symbol,Keyword,String or Map");
                    }
                }

                object o = ReadAux(r, opts);

                if (o is IMeta)
                {
                    if (startLine != -1 && o is ISeq)
                    {
                        metaAsMap = metaAsMap.assoc(RT.LineKey, startLine)
                                    .assoc(RT.ColumnKey, startCol)
                                    .assoc(RT.SourceSpanKey, RT.map(
                                               RT.StartLineKey, startLine,
                                               RT.StartColumnKey, startCol,
                                               RT.EndLineKey, lntr.LineNumber,
                                               RT.EndColumnKey, lntr.ColumnNumber));
                    }

                    IReference iref = o as IReference;
                    if (iref != null)
                    {
                        iref.resetMeta(metaAsMap);
                        return(o);
                    }
                    object ometa = RT.meta(o);
                    for (ISeq s = RT.seq(metaAsMap); s != null; s = s.next())
                    {
                        IMapEntry kv = (IMapEntry)s.first();
                        ometa = RT.assoc(ometa, kv.key(), kv.val());
                    }
                    return(((IObj)o).withMeta((IPersistentMap)ometa));
                }
                else
                {
                    throw new ArgumentException("Metadata can only be applied to IMetas");
                }
            }
 /// <summary>
 ///   Initializes a new instance of the <see cref = "CreateOnUIThreadInspector" /> class.
 /// </summary>
 /// <param name = "kernel">The kernel.</param>
 /// <param name = "config">The config.</param>
 public CreateOnUIThreadInspector(IKernel kernel, IConfiguration config)
 {
     marshalingControl = new MarshalingControl();
     controlProxyHook  = ObtainProxyHook(kernel, config);
 }
Exemplo n.º 52
0
        void InvokeTyped(VMContext ctx, MethodBase targetMethod, byte opCode, ref uint sp, out ExecutionState state)
        {
            var parameters = targetMethod.GetParameters();
            int paramCount = parameters.Length;

            if (!targetMethod.IsStatic && opCode != Constants.ECALL_NEWOBJ)
            {
                paramCount++;
            }

            Type constrainType = null;

            if (opCode == Constants.ECALL_CALLVIRT_CONSTRAINED)
            {
                constrainType = (Type)ctx.Instance.Data.LookupReference(ctx.Stack[sp--].U4);
            }

            int indexOffset = (targetMethod.IsStatic || opCode == Constants.ECALL_NEWOBJ) ? 0 : 1;

            IReference[] references = new IReference[paramCount];
            Type[]       types      = new Type[paramCount];
            for (int i = paramCount - 1; i >= 0; i--)
            {
                Type paramType;
                if (!targetMethod.IsStatic && opCode != Constants.ECALL_NEWOBJ)
                {
                    if (i == 0)
                    {
                        if (!targetMethod.IsStatic)
                        {
                            var thisSlot = ctx.Stack[sp];
                            if (thisSlot.O is ValueType && !targetMethod.DeclaringType.IsValueType)
                            {
                                Debug.Assert(targetMethod.DeclaringType.IsInterface);
                                Debug.Assert(opCode == Constants.ECALL_CALLVIRT);
                                // Interface dispatch on valuetypes => use constrained. invocation
                                constrainType = thisSlot.O.GetType();
                            }
                        }

                        if (constrainType != null)
                        {
                            paramType = constrainType.MakeByRefType();
                        }
                        else if (targetMethod.DeclaringType.IsValueType)
                        {
                            paramType = targetMethod.DeclaringType.MakeByRefType();
                        }
                        else
                        {
                            paramType = targetMethod.DeclaringType;
                        }
                    }
                    else
                    {
                        paramType = parameters[i - 1].ParameterType;
                    }
                }
                else
                {
                    paramType = parameters[i].ParameterType;
                }
                references[i] = PopRef(ctx, paramType, ref sp);
                if (paramType.IsByRef)
                {
                    paramType = paramType.GetElementType();
                }
                types[i] = paramType;
            }

            OpCode callOp;
            Type   retType;

            if (opCode == Constants.ECALL_CALL)
            {
                callOp  = System.Reflection.Emit.OpCodes.Call;
                retType = targetMethod is MethodInfo ? ((MethodInfo)targetMethod).ReturnType : typeof(void);
            }
            else if (opCode == Constants.ECALL_CALLVIRT ||
                     opCode == Constants.ECALL_CALLVIRT_CONSTRAINED)
            {
                callOp  = System.Reflection.Emit.OpCodes.Callvirt;
                retType = targetMethod is MethodInfo ? ((MethodInfo)targetMethod).ReturnType : typeof(void);
            }
            else if (opCode == Constants.ECALL_NEWOBJ)
            {
                callOp  = System.Reflection.Emit.OpCodes.Newobj;
                retType = targetMethod.DeclaringType;
            }
            else
            {
                throw new InvalidProgramException();
            }
            var proxy = DirectCall.GetTypedInvocationProxy(targetMethod, callOp, constrainType);

            object result = proxy(ctx, references, types);

            if (retType != typeof(void))
            {
                ctx.Stack[++sp] = VMSlot.FromObject(result, retType);
            }
            else if (opCode == Constants.ECALL_NEWOBJ)
            {
                ctx.Stack[++sp] = VMSlot.FromObject(result, retType);
            }

            ctx.Stack.SetTopPosition(sp);
            ctx.Registers[Constants.REG_SP].U4 = sp;
            state = ExecutionState.Next;
        }
Exemplo n.º 53
0
 public void Add(IReference reference)
 {
     objects.Add(reference);
 }
Exemplo n.º 54
0
        /// <summary>
        /// Adds or replaces a reference.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <param name="value">The value.</param>
        /// <param name="replace">if set to <c>true</c> reference is replaced.</param>
        private void Add(IReference key, T value, bool replace)
        {
            // validate key.
            ValidateReference(key, true);

            m_version++;

            // look up the reference type.
            ReferenceTypeEntry entry = null;

            if (!m_references.TryGetValue(key.ReferenceTypeId, out entry))
            {
                entry = new ReferenceTypeEntry();
                m_references.Add(key.ReferenceTypeId, entry);
            }

            // handle reference to external targets.
            if (key.TargetId.IsAbsolute)
            {
                Dictionary <ExpandedNodeId, LinkedListNode <KeyValuePair <IReference, T> > > targets = null;

                if (key.IsInverse)
                {
                    if (entry.InverseExternalTargets == null)
                    {
                        entry.InverseExternalTargets = new Dictionary <ExpandedNodeId, LinkedListNode <KeyValuePair <IReference, T> > >();
                    }

                    targets = entry.InverseExternalTargets;
                }
                else
                {
                    if (entry.ForwardExternalTargets == null)
                    {
                        entry.ForwardExternalTargets = new Dictionary <ExpandedNodeId, LinkedListNode <KeyValuePair <IReference, T> > >();
                    }

                    targets = entry.ForwardExternalTargets;
                }

                // create a new target.
                LinkedListNode <KeyValuePair <IReference, T> > node = new LinkedListNode <KeyValuePair <IReference, T> >(new KeyValuePair <IReference, T>(key, value));

                // check if target already exists.
                LinkedListNode <KeyValuePair <IReference, T> > existingNode = null;

                if (!targets.TryGetValue(key.TargetId, out existingNode))
                {
                    existingNode = node;
                    m_list.AddLast(node);
                }

                // need to replace reference in linked linked as well as the target list.
                else
                {
                    if (!replace)
                    {
                        throw new ArgumentException("Key already exists in dictionary.", "key");
                    }

                    m_list.AddAfter(existingNode, node);
                    m_list.Remove(existingNode);
                }

                targets[key.TargetId] = node;
            }

            // handle reference to internal target.
            else
            {
                NodeIdDictionary <LinkedListNode <KeyValuePair <IReference, T> > > targets = null;

                if (key.IsInverse)
                {
                    if (entry.InverseTargets == null)
                    {
                        entry.InverseTargets = new NodeIdDictionary <LinkedListNode <KeyValuePair <IReference, T> > >();
                    }

                    targets = entry.InverseTargets;
                }
                else
                {
                    if (entry.ForwardTargets == null)
                    {
                        entry.ForwardTargets = new NodeIdDictionary <LinkedListNode <KeyValuePair <IReference, T> > >();
                    }

                    targets = entry.ForwardTargets;
                }

                NodeId targetId = (NodeId)key.TargetId;

                // create a new target.
                LinkedListNode <KeyValuePair <IReference, T> > node = new LinkedListNode <KeyValuePair <IReference, T> >(new KeyValuePair <IReference, T>(key, value));

                // check if target already exists.
                LinkedListNode <KeyValuePair <IReference, T> > existingNode = null;

                if (!targets.TryGetValue(targetId, out existingNode))
                {
                    existingNode = node;
                    m_list.AddLast(node);
                }

                // need to replace reference in linked linked as well as the target list.
                else
                {
                    if (!replace)
                    {
                        throw new ArgumentException("Key already exists in dictionary.", "key");
                    }

                    m_list.AddAfter(existingNode, node);
                    m_list.Remove(existingNode);
                }

                targets[targetId] = node;
            }
        }
Exemplo n.º 55
0
 public IReferenceOrISignature(IReference item) => _item = item;
Exemplo n.º 56
0
 public ProxyHookDescriptor(IReference <IProxyGenerationHook> hook)
 {
     this.hook = hook;
 }
Exemplo n.º 57
0
 public AddChildMenuItem(IReference containment, System.Type newElementType, IModelElement element)
 {
     this.containment    = containment;
     this.newElementType = newElementType;
     this.element        = element;
 }
Exemplo n.º 58
0
 public IReferenceOrISignatureEquivalent(IReference item) => _item = item;
Exemplo n.º 59
0
 /// <summary cref="ICollection{T}.Remove" />
 public bool Remove(IReference item)
 {
     return(m_references.Remove(item));
 }
Exemplo n.º 60
0
 /// <summary cref="ICollection{T}.Contains" />
 public bool Contains(IReference item)
 {
     return(m_references.ContainsKey(item));
 }