コード例 #1
0
        public AttributeDefinition(IMetaModel metaModel, XmlElement element)
        {
            this.metaModel = metaModel;

            token = element.GetAttribute("token");

            TextBuilder.SplitPrefix(token, '.', out assetTypeToken, out name);

            displayName = element.GetAttribute("displayname");
            attributeType = (AttributeType)Enum.Parse(typeof(AttributeType), element.GetAttribute("attributetype"));

            isReadonly = bool.Parse(element.GetAttribute("isreadonly"));
            isRequired = bool.Parse(element.GetAttribute("isrequired"));
            isMultivalue = bool.Parse(element.GetAttribute("ismultivalue"));

            var baseelement = element.SelectSingleNode("Base") as XmlElement;

            if (baseelement != null)
            {
                baseToken = baseelement.GetAttribute("tokenref");
            }

            var relatedelement = element.SelectSingleNode("RelatedAsset") as XmlElement;

            if (relatedelement != null)
            {
                relatedAssetToken = relatedelement.GetAttribute("nameref");
            }

            ((AssetType)AssetType).SaveAttributeDefinition(this);
        }
コード例 #2
0
ファイル: FileIO.cs プロジェクト: jblomer/GrGen.NET
 public FileIO(IGraph g)
 {
     try
     {
         graph = g;
         outputnodetype = g.Model.NodeModel.GetType("grIO_OUTPUT");
         if (outputnodetype == null) throw new Exception();
         createOrOverwriteType = g.Model.EdgeModel.GetType("grIO_CreateOrOverwrite");
         if (createOrOverwriteType == null) throw new Exception();
         createOrAppendType = g.Model.EdgeModel.GetType("grIO_CreateOrAppend");
         if (createOrAppendType == null) throw new Exception();
         fileType = g.Model.NodeModel.GetType("grIO_File");
         if (fileType == null) throw new Exception();
         fileNameAttrType = fileType.GetAttributeType("path");
         if (fileNameAttrType == null) throw new Exception();
         lineType = g.Model.NodeModel.GetType("grIO_File_Line");
         if (lineType == null) throw new Exception();
         containsLineType = g.Model.EdgeModel.GetType("grIO_File_ContainsLine");
         if (containsLineType == null) throw new Exception();
         nextLineType = g.Model.EdgeModel.GetType("grIO_File_NextLine");
         if (nextLineType == null) throw new Exception();
         lineContentAttrType = lineType.GetAttributeType("content");
         if (lineContentAttrType == null) throw new Exception();
     }
     catch (Exception)
     {
         throw new Exception("Could not find the required node/edge types. Did you include the GrIO-model?");
     }
 }
コード例 #3
0
        /// <summary>
        /// Factory method to create <see cref="AttributeValueBase"/> based class by specified <see cref="AttributeType"/> value.
        /// </summary>
        /// <param name="type">Attribute type</param>
        /// <returns><see cref="AttributeValueBase"/> based class</returns>
        public static AttributeValueBase CreateByType(AttributeType type)
        {
            switch (type)
            {
                case AttributeType.Integer:
                    return new AttributeValueInt32();
                case AttributeType.Bigint:
                    return new AttributeValueInt64();
                case AttributeType.Ordinal:
                    return new AttributeValueOrdinal();
                case AttributeType.Float:
                    return new AttributeValueFloat();
                case AttributeType.Timestamp:
                    return new AttributeValueDateTime();
                case AttributeType.Boolean:
                    return new AttributeValueBoolean();
				case AttributeType.String:
            		return new AttributeValueString();
                case AttributeType.MultiInteger:
                    return new AttributeValuesInt32();
                case AttributeType.MultiLong:
                    return new AttributeValuesInt64();
            }
            throw new NotSupportedException(String.Format(Messages.Exception_UnsupportedAttributeType, Enum.GetName(typeof(AttributeType), type)));
        }
コード例 #4
0
ファイル: DynamicConfig.cs プロジェクト: gowhy/LoveBank
 public DynamicConfig(string key,string title, AttributeType input, object value = null)
 {
     Key = key;
     Title = title;
     Type = input;
     Value = value;
 }
コード例 #5
0
 /// <summary>
 ///     Static method to return generated code for a single JSON schema with no references.
 /// </summary>
 /// <param name="schema">Location of schema file.</param>
 /// <param name="ns">The namespace.</param>
 /// <param name="type">The attribute type.</param>
 /// <returns>The generated code.</returns>
 public static string Generate(string schema, string ns = "generated", AttributeType type = AttributeType.SystemDefault)
 {
     var jsonSchemaToCodeUnit = new JsonSchemaToCodeUnit(JsonSchemaResolver.ConvertToWrapper(schema), ns, type);
     CodeCompileUnit codeUnit = jsonSchemaToCodeUnit.Execute();
     var csharpGenerator = new CodeCompileUnitToCSharp(codeUnit);
     return csharpGenerator.Execute();
 }
コード例 #6
0
        public NtfsFileStream(NtfsFileSystem fileSystem, DirectoryEntry entry, AttributeType attrType, string attrName, FileAccess access)
        {
            _entry = entry;

            _file = fileSystem.GetFile(entry.Reference);
            _baseStream = _file.OpenStream(attrType, attrName, access);
        }
コード例 #7
0
ファイル: TestAttributeInfo.cs プロジェクト: Joxx0r/ATF
        public void TestDefaultValue()
        {
            AttributeType type = new AttributeType("test", typeof(string));
            AttributeInfo test = new AttributeInfo("test", type);
            test.DefaultValue = "foo";
            Assert.AreEqual(test.DefaultValue, "foo");
            test.DefaultValue = null;
            Assert.AreEqual(test.DefaultValue, type.GetDefault());
            Assert.Throws<InvalidOperationException>(delegate { test.DefaultValue = 1; });

            AttributeType length2Type = new AttributeType("length2Type", typeof(int[]), 2);
            AttributeInfo length2Info = new AttributeInfo("length2", length2Type);
            Assert.AreEqual(length2Info.DefaultValue, length2Type.GetDefault());
            Assert.AreEqual(length2Info.DefaultValue, new int[] { default(int), default(int) });
            DomNodeType nodeType = new DomNodeType("testNodeType");
            nodeType.Define(length2Info);
            DomNode node = new DomNode(nodeType);
            Assert.AreEqual(node.GetAttribute(length2Info), length2Info.DefaultValue);
            node.SetAttribute(length2Info, new int[] { 1, 2 });
            Assert.AreEqual(node.GetAttribute(length2Info), new int[] { 1, 2 });
            node.SetAttribute(length2Info, new int[] { 1 });
            Assert.AreEqual(node.GetAttribute(length2Info), new int[] { 1 });

            AttributeType length1Type = new AttributeType("length1Type", typeof(int[]), 1);
            AttributeInfo length1Info = new AttributeInfo("length1", length1Type);
            Assert.AreEqual(length1Info.DefaultValue, length1Type.GetDefault());
            Assert.AreEqual(length1Info.DefaultValue, new int[] { default(int) });
            nodeType = new DomNodeType("testNodeType");
            nodeType.Define(length1Info);
            node = new DomNode(nodeType);
            Assert.AreEqual(node.GetAttribute(length1Info), length1Info.DefaultValue);
            node.SetAttribute(length1Info, new int[] { 1 });
            Assert.AreEqual(node.GetAttribute(length1Info), new int[] { 1 });
        }
コード例 #8
0
ファイル: AppDetails.cs プロジェクト: brentmaxwell/php-auth
 public static string Get(AttributeType attr)
 {
     string output = "";
     switch (attr)
     {
         case AttributeType.Title:
             AssemblyTitleAttribute title = (AssemblyTitleAttribute)Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyTitleAttribute));
             output = title.Title;
             break;
         case AttributeType.Product:
             AssemblyProductAttribute product = (AssemblyProductAttribute)Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyProductAttribute));
             output = product.Product;
             break;
         case AttributeType.Description:
             AssemblyDescriptionAttribute description = (AssemblyDescriptionAttribute)Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyDescriptionAttribute));
             output = description.Description;
             break;
         case AttributeType.Copyright:
             AssemblyCopyrightAttribute copyright = (AssemblyCopyrightAttribute)Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyCopyrightAttribute));
             output = copyright.Copyright;
             break;
         case AttributeType.Company:
             AssemblyCompanyAttribute company = (AssemblyCompanyAttribute)Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyCompanyAttribute));
             output = company.Company;
             break;
         case AttributeType.Version:
             output = Assembly.GetExecutingAssembly().GetName().Version.ToString();
             break;
     }
     return output;
 }
コード例 #9
0
 public static AttributeUpdateBase CreateByType(AttributeType type)
 {
     switch (type)
     {
         case AttributeType.Integer:
             return new AttributeUpdateInt32();
         case AttributeType.Float:
             return new AttributeUpdateFloat();
         case AttributeType.Timestamp:
             return new AttributeUpdateDateTime();
         case AttributeType.Boolean:
             return new AttributeUpdateBoolean();
         case AttributeType.Ordinal:
             return new AttributeUpdateOrdinal();
         case AttributeType.MultiBoolean:
             return new AttributeUpdateMultiBoolean();
         case AttributeType.MultiFloat:
             return new AttributeUpdateMultiFloat();
         case AttributeType.MultiInteger:
             return new AttributeUpdateMultiInt32();
         case AttributeType.MultiOrdinal:
             return new AttributeUpdateMultiOrdinal();
         case AttributeType.MultiTimestamp:
             return new AttributeUpdateMultiDateTime();
         // NOTE: Bigint (64-bit) attribute type currently is not supported by Sphinx server (0.9.9-rc2)
     }
     throw new NotSupportedException(String.Format(Messages.Exception_UnsupportedAttributeType, Enum.GetName(typeof(AttributeType), type)));
 }
コード例 #10
0
 public ResidentAttributeRecord(AttributeType type, string name, ushort id, bool indexed, AttributeFlags flags)
     : base(type, name, id, flags)
 {
     _nonResidentFlag = 0;
     _indexedFlag = (byte)(indexed ? 1 : 0);
     _memoryBuffer = new SparseMemoryBuffer(1024);
 }
コード例 #11
0
ファイル: TestAttributeInfo.cs プロジェクト: Joxx0r/ATF
 public void TestConstructor()
 {
     AttributeType type = new AttributeType("test", typeof(string));
     AttributeInfo test = new AttributeInfo("test", type);
     Assert.AreEqual(test.Name, "test");
     Assert.AreEqual(test.Type, type);
     Assert.AreEqual(test.DefaultValue, type.GetDefault());
 }
コード例 #12
0
ファイル: AttDef.cs プロジェクト: roomaroo/coapp.powershell
        /// <summary>
        ///     Sets the attribute definition to have an enumerated value.
        /// </summary>
        /// <param name="enumValues">The possible values in the enumeration.</param>
        /// <param name="type">The type to set the attribute to.</param>
        /// <exception cref="ArgumentException">
        ///     If the type parameter is not either <see cref="AttributeType.ENUMERATION" /> or <see cref="AttributeType.NOTATION" />.
        /// </exception>
        public void SetEnumeratedType(string[] enumValues, AttributeType type) {
            if (type != AttributeType.ENUMERATION && type != AttributeType.NOTATION) {
                throw new ArgumentException(string.Format(CultureInfo.CurrentUICulture, "AttributeType {0} is not valid for an attribute definition with an enumerated value.", type));
            }

            m_enumValues = enumValues;
            m_type = type;
        }
コード例 #13
0
ファイル: AttributePool.cs プロジェクト: tryonn/GameStartUP
 public Attribute GetAttribute(AttributeType targetAttribute)
 {
     if (!attributes.ContainsKey(targetAttribute))
     {
         Debug.Log("Can't found any attribute of type: " + targetAttribute, this);
         return null;
     }
     return attributes[targetAttribute];
 }
コード例 #14
0
ファイル: Attributes.cs プロジェクト: GSazheniuk/HOO
 public List<OAttribute> ListByType(AttributeType attributeType)
 {
     //			var res = this._ah.Where (oa => oa.Value.AttributeType == (int)attributeType);
     //			if (res != null) {
     ////				return res.Select(oa=>oa.Value).ToList();
     //				return new List<OAttribute> ();
     //			} else
         return new List<OAttribute> ();
 }
コード例 #15
0
ファイル: Stun.cs プロジェクト: pstjuste/brunet
 /// <summary>Create a new Attribute.</summary>
 public Attribute(AttributeType type, MemBlock value)
 {
   Type = type;
   Value = value;
   byte[] data = new byte[4 + value.Length];
   NumberSerializer.WriteUShort((ushort) type, data, 0);
   NumberSerializer.WriteUShort((ushort) value.Length, data, 2);
   value.CopyTo(data, 4);
   Data = MemBlock.Reference(data);
 }
コード例 #16
0
 internal void RegisterAttribute(Type fieldType, string attrName, AttributeType type)
 {
     Dictionary<string, AttributeType> fieldsForType;
     if (!_registry.TryGetValue(fieldType, out fieldsForType))
     {
         fieldsForType = new Dictionary<string, AttributeType>();
         _registry.Add(fieldType, fieldsForType);
     }
     fieldsForType.Add(attrName, type);
 }
コード例 #17
0
ファイル: Attribute.cs プロジェクト: ciavy/ProjectONE
        public string value_string { get; set; } //value of the attribute. only needed if type is string

        /**
         * Note: if t = STRING => lb and ub are excluded automatically
         */
        public Attribute(String name, AttributeType t, int lb, int ub)
        {
            this.Name = name;
            this.type = t;
            if (t != AttributeType.STRING)
            {
                this.upperbound = ub;
                this.lowerbound = lb;
            }
        }
コード例 #18
0
 internal void Read(byte[] buffer, int offset)
 {
     Name = Encoding.Unicode.GetString(buffer, offset + 0, 128).Trim('\0');
     Type = (AttributeType)Utilities.ToUInt32LittleEndian(buffer, offset + 0x80);
     DisplayRule = Utilities.ToUInt32LittleEndian(buffer, offset + 0x84);
     CollationRule = (AttributeCollationRule)Utilities.ToUInt32LittleEndian(buffer, offset + 0x88);
     Flags = (AttributeTypeFlags)Utilities.ToUInt32LittleEndian(buffer, offset + 0x8C);
     MinSize = Utilities.ToInt64LittleEndian(buffer, offset + 0x90);
     MaxSize = Utilities.ToInt64LittleEndian(buffer, offset + 0x98);
 }
コード例 #19
0
        public void TestEquality()
        {
            var attrType1 = new AttributeType("xkcd", typeof(string));
            var attrInfo1 = new AttributeInfo("xkcd", attrType1);
            var domNodeType = new DomNodeType("WebComic", DomNodeType.BaseOfAllTypes);
            var childInfo1 = new ChildInfo("xkcd", domNodeType);
            attrInfo1.DefaultValue = "Firefly";
            var desc1 = new ChildAttributePropertyDescriptor(
                "xkcd", attrInfo1, childInfo1, "Category 1", "A commonly used word or phrase in the xkcd comic", true);
            int originalHashCode = desc1.GetHashCode();

            // test if two identically created property descriptors compare as being equal
            var desc2 = new ChildAttributePropertyDescriptor(
                "xkcd", attrInfo1, childInfo1, "Category 1", "A commonly used word or phrase in the xkcd comic", true);
            Assert.AreEqual(desc1, desc2);
            Assert.AreEqual(desc1.GetHashCode(), desc2.GetHashCode());

            // test category being different; oddly, although I think they should not be considered equal,
            //  the .Net PropertyDescriptor ignores the difference in category name. So, I'm guessing that
            //  the AttributePropertyDescriptor should behave the same as PropertyDescriptor.
            var desc3 = new ChildAttributePropertyDescriptor(
                "xkcd", attrInfo1, childInfo1, "Category 2", "A commonly used word or phrase in the xkcd comic", true);
            Assert.AreEqual(desc1, desc3);
            Assert.AreEqual(desc1.GetHashCode(), desc3.GetHashCode());

            // test description being different; similarly here, the .Net PropertyDescriptor doesn't care.
            var desc4 = new ChildAttributePropertyDescriptor(
                "xkcd", attrInfo1, childInfo1, "Category 1", "slightly different description", true);
            Assert.AreEqual(desc1, desc4);
            Assert.AreEqual(desc1.GetHashCode(), desc4.GetHashCode());

            // test readOnly being different; ditto for read-only flag!
            var desc5 = new ChildAttributePropertyDescriptor(
                "xkcd", attrInfo1, childInfo1, "Category 1", "A commonly used word or phrase in the xkcd comic", false);
            Assert.AreEqual(desc1, desc5);
            Assert.AreEqual(desc1.GetHashCode(), desc5.GetHashCode());

            // test that the hash code hasn't changed after using the AttributeInfo
            var attrInfo2 = new AttributeInfo("xkcd", attrType1);
            domNodeType.Define(attrInfo2);
            Assert.AreEqual(desc1.GetHashCode(), originalHashCode);

            // test that the hash code hasn't changed after creating a derived DomNodeType
            var derivedDomNodeType = new DomNodeType("ScientificWebComic", domNodeType);
            var derivedAttrInfo = new AttributeInfo("xkcd", attrType1);
            var derivedChildInfo = new ChildInfo("xkcd", derivedDomNodeType);
            derivedDomNodeType.Define(derivedAttrInfo);
            Assert.AreEqual(desc1.GetHashCode(), originalHashCode);

            // test that an AttributeInfo used in a derived DomNodeType doesn't change equality or hash code
            var desc6 = new ChildAttributePropertyDescriptor(
                "xkcd", derivedAttrInfo, derivedChildInfo, "Category 1", "A commonly used word or phrase in the xkcd comic", true);
            Assert.AreEqual(desc1, desc6);
            Assert.AreEqual(desc1.GetHashCode(), desc6.GetHashCode());
        }
コード例 #20
0
        public void SetUp()
        {
            var assemblies = new[]
            {
                typeof(Umbraco.Tests.Extensions.TestDynamicExtensions).Assembly
            };
            var supportedDynamicTypes = new[]
            {
                typeof(Content),
                typeof(BendyObject)
            };
            var supportedDynamicFieldTypes = new[]
            {
                typeof(Content),
                typeof(TypedAttribute),
                typeof(BendyObject)
            };
            var bendyMethods = DynamicExtensionsHelper.GetExtensions(assemblies, supportedDynamicTypes);
            var subBendyMethods = DynamicExtensionsHelper.GetExtensions<DynamicFieldExtensionAttribute>(assemblies, supportedDynamicFieldTypes);

            var bendy = new BendyObject();

            BendyObjectExtensionsHelper.ApplyDynamicExtensions<Content>(bendy, bendyMethods);

            var content = new Content();

            _bendy = bendy;
            _bendy["__OriginalItem"] = content;

            var attrType1 = new AttributeType {RenderTypeProvider = CorePluginConstants.FileUploadPropertyEditorId};
            var attrDef1 = new AttributeDefinition {AttributeType = attrType1};
            var attr1 = new TypedAttribute(attrDef1);

            var subBendy1 = new BendyObject();
            subBendy1["__OriginalItem"] = attr1;
            subBendy1.AddLazy("__Parent", () => bendy);
            subBendy1["__ParentKey"] = "Test";

            BendyObjectExtensionsHelper.ApplyDynamicFieldExtensions(content, CorePluginConstants.FileUploadPropertyEditorId, subBendy1, subBendyMethods);

            _bendy["Test"] = subBendy1;

            var attrType2 = new AttributeType { RenderTypeProvider = CorePluginConstants.TreeNodePickerPropertyEditorId };
            var attrDef2 = new AttributeDefinition { AttributeType = attrType2 };
            var attr2 = new TypedAttribute(attrDef2);

            var subBendy2 = new BendyObject();
            subBendy2["__OriginalItem"] = attr2;
            subBendy2.AddLazy("__Parent", () => bendy);
            subBendy2["__ParentKey"] = "Test2";

            BendyObjectExtensionsHelper.ApplyDynamicFieldExtensions(content, CorePluginConstants.TreeNodePickerPropertyEditorId, subBendy2, subBendyMethods);

            _bendy["Test2"] = subBendy2;
        }
コード例 #21
0
        public AttributesParser(AttributeType[] attributeTypes)
        {
            _attributeTypesMap = new Dictionary<string,AttributeType>();
            _parsedAttributesMap = null;

            if( attributeTypes != null )
            {
                foreach( AttributeType attributeType in attributeTypes )
                    _attributeTypesMap.Add(attributeType.Name,attributeType);
            }
        }
コード例 #22
0
ファイル: Attributes.cs プロジェクト: GSazheniuk/HOO
 public bool ContainsAttribute(ObjectAttribute attribute, AttributeType attributeType)
 {
     try
     {
         //return this._attrs.Any(oa => oa.AttributeID == (int)attribute && oa.AttributeType == (int)attributeType);
     }
     catch (Exception ex) {
         throw ex;
     }
     return false;
 }
コード例 #23
0
 /// <summary>
 ///     Creates the attribute.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="required">if set to <c>true</c> [required].</param>
 /// <param name="rule">The rule.</param>
 /// <param name="type">The type.</param>
 /// <returns>Attribute instance.</returns>
 private static Attribute CreateAttribute(string name, bool required, string rule, AttributeType type = AttributeType.String)
 {
     var attribute = new Attribute
     {
         Name = name,
         AttributeType = type,
         Required = required,
         Rule = rule
     };
     return attribute;
 }
コード例 #24
0
        public JsonSchemaToCodeUnit(JsonSchemaWrapper schema, string requestedNamespace, AttributeType attributeType)
        {
            if (schema == null || schema.Schema == null)
            {
                throw new ArgumentNullException("schema");
            }

            _schemaWrapper = schema;
            _schemaDocument = schema.Schema;
            _codeNamespace = requestedNamespace;
            _attributeType = attributeType;
        }
コード例 #25
0
ファイル: File.cs プロジェクト: joconno4/MediaPortal-2
        public int MftRecordFreeSpace(AttributeType attrType, string attrName)
        {
            foreach(var record in _records)
            {
                if(record.GetAttribute(attrType, attrName) != null)
                {
                    return _mft.RecordSize - record.Size;
                }
            }

            throw new IOException("Attempt to determine free space for non-existent attribute");
        }
コード例 #26
0
ファイル: Attribute.cs プロジェクト: subbuballa/Walkyr
        public Attribute(String id, AttributeType type, String title)
        {
            //		    checkArgument(id != null, "ID cannot be null.");
            //		    checkArgument(!id.trim().isEmpty(), "ID cannot be empty or blank.");
            //		    checkArgument(title != null, "Title cannot be null.");
            //		    checkArgument(!title.trim().isEmpty(), "Title cannot be null or blank.");

            Id = id;
            AttributeType = type;
            this.options = new List<String>();
            Title = title;
        }
コード例 #27
0
ファイル: Attribute.cs プロジェクト: ciavy/ProjectONE
 //Needed for test. Attribute with fixed value
 public Attribute(String name, AttributeType t, string value)
 {
     this.Name = name;
     this.type = t;
     switch (t)
     {
         case AttributeType.INT:
             this.value_int = int.Parse(value);
             break;
         case AttributeType.STRING:
             this.value_string = value;
             break;
     }
 }
コード例 #28
0
ファイル: AttDef.cs プロジェクト: NoobSkie/taobao-shop-helper
 public void SetType(string type)
 {
     switch (type)
     {
         case "CDATA":
             Type = AttributeType.CDATA;
             break;
         case "ENTITY":
             Type = AttributeType.ENTITY;
             break;
         case "ENTITIES":
             Type = AttributeType.ENTITIES;
             break;
         case "ID":
             Type = AttributeType.ID;
             break;
         case "IDREF":
             Type = AttributeType.IDREF;
             break;
         case "IDREFS":
             Type = AttributeType.IDREFS;
             break;
         case "NAME":
             Type = AttributeType.NAME;
             break;
         case "NAMES":
             Type = AttributeType.NAMES;
             break;
         case "NMTOKEN":
             Type = AttributeType.NMTOKEN;
             break;
         case "NMTOKENS":
             Type = AttributeType.NMTOKENS;
             break;
         case "NUMBER":
             Type = AttributeType.NUMBER;
             break;
         case "NUMBERS":
             Type = AttributeType.NUMBERS;
             break;
         case "NUTOKEN":
             Type = AttributeType.NUTOKEN;
             break;
         case "NUTOKENS":
             Type = AttributeType.NUTOKENS;
             break;
         default:
             throw new Exception("Attribute type '" + type + "' is not supported");
     }
 }
コード例 #29
0
        public NonResidentAttributeRecord(AttributeType type, string name, ushort id, AttributeFlags flags, long firstCluster, ulong numClusters, uint bytesPerCluster)
            : base(type, name, id, flags)
        {
            _nonResidentFlag = 1;
            _dataRuns = new List<DataRun>();
            _dataRuns.Add(new DataRun(firstCluster, (long)numClusters, false));
            _lastVCN = numClusters - 1;
            _dataAllocatedSize = bytesPerCluster * numClusters;
            _dataRealSize = bytesPerCluster * numClusters;
            _initializedDataSize = bytesPerCluster * numClusters;

            if ((flags & (AttributeFlags.Compressed | AttributeFlags.Sparse)) != 0)
            {
                _compressionUnitSize = DefaultCompressionUnitSize;
            }
        }
コード例 #30
0
ファイル: TestAttributeInfo.cs プロジェクト: Joxx0r/ATF
        public void TestValidation()
        {
            AttributeType type = new AttributeType("test", typeof(string));
            AttributeInfo test = new AttributeInfo("test", type);
            CollectionAssert.IsEmpty(test.Rules);

            var rule = new SimpleAttributeRule();
            test.AddRule(rule);

            Utilities.TestSequenceEqual(test.Rules, rule);

            Assert.True(test.Validate("bar"));
            Assert.True(rule.Validated);

            Assert.False(test.Validate(1)); // wrong type
        }
コード例 #31
0
        /// <summary>
        /// Creates a Version 1.1 Saml Assertion
        /// </summary>
        /// <param name="issuer">Issuer</param>
        /// <param name="subject">Subject</param>
        /// <param name="attributes">Attributes</param>
        /// <returns>returns a Version 2.0 Saml Assertion</returns>
        private static AssertionType CreateSamlAssertion(string issuer, string recipient, string subject, string audience, string nameIdPolicyFormat, Dictionary <string, string> attributes)
        {
            // Here we create some SAML assertion with ID and Issuer name.
            AssertionType assertion = new AssertionType();

            assertion.ID = "_" + Guid.NewGuid().ToString();

            NameIDType issuerForAssertion = new NameIDType();

            issuerForAssertion.Value = issuer.Trim();

            assertion.Issuer  = issuerForAssertion;
            assertion.Version = "2.0";

            assertion.IssueInstant = System.DateTime.UtcNow;

            //Not before, not after conditions
            ConditionsType conditions = new ConditionsType();

            conditions.NotBefore             = DateTime.UtcNow;
            conditions.NotBeforeSpecified    = true;
            conditions.NotOnOrAfter          = DateTime.UtcNow.AddMinutes(5);
            conditions.NotOnOrAfterSpecified = true;

            AudienceRestrictionType audienceRestriction = new AudienceRestrictionType();

            audienceRestriction.Audience = new string[] { audience.Trim() };

            conditions.Items = new ConditionAbstractType[] { audienceRestriction };

            //Name Identifier to be used in Saml Subject
            NameIDType nameIdentifier = new NameIDType();

            //nameIdentifier.NameQualifier = domain.Trim();
            nameIdentifier.Format = nameIdPolicyFormat;
            nameIdentifier.Value  = subject.Trim();

            SubjectConfirmationType     subjectConfirmation     = new SubjectConfirmationType();
            SubjectConfirmationDataType subjectConfirmationData = new SubjectConfirmationDataType();

            subjectConfirmation.Method = "urn:oasis:names:tc:SAML:2.0:cm:bearer";

            subjectConfirmation.SubjectConfirmationData = subjectConfirmationData;
            //
            // Create some SAML subject.
            SubjectType samlSubject = new SubjectType();

            AttributeStatementType attrStatement = new AttributeStatementType();
            AuthnStatementType     authStatement = new AuthnStatementType();

            authStatement.AuthnInstant = DateTime.UtcNow;
            AuthnContextType context = new AuthnContextType();

            context.ItemsElementName   = new ItemsChoiceType5[] { ItemsChoiceType5.AuthnContextClassRef };
            context.Items              = new object[] { "urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified" };
            authStatement.AuthnContext = context;

            samlSubject.Items = new object[] { nameIdentifier, subjectConfirmation };

            assertion.Subject = samlSubject;

            IPHostEntry ipEntry =
                Dns.GetHostEntry(System.Environment.MachineName);

            SubjectLocalityType subjectLocality = new SubjectLocalityType();

            subjectLocality.Address = ipEntry.AddressList[0].ToString();

            attrStatement.Items = new AttributeType[attributes.Count];
            int i = 0;

            // Create userName SAML attributes.
            foreach (KeyValuePair <string, string> attribute in attributes)
            {
                AttributeType attr = new AttributeType();
                attr.Name = attribute.Key;
                //attr.NameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:basic";
                attr.AttributeValue    = new object[] { attribute.Value };
                attrStatement.Items[i] = attr;
                i++;
            }
            assertion.Conditions = conditions;

            assertion.Items = new StatementAbstractType[] { authStatement, attrStatement };

            return(assertion);
        }
コード例 #32
0
        /// <summary>
        /// Sets up the query object and validates the passed in parameters to ensure they are compatible with each other
        /// </summary>
        /// <param name="attributeName">The name of the attribute being queried</param>
        /// <param name="comparisonOperator">THe value comparison operator to use</param>
        /// <param name="value">The value to use in the query</param>
        /// <param name="negate">Indicates if the query should be negated with the not() operator</param>
        /// <param name="attributeType">The type of the target attribute</param>
        /// <param name="isMultivalued">The multivalued status of the attribute being queried</param>
        private void SetupBuilder(string attributeName, ComparisonOperator comparisonOperator, object value, bool negate, AttributeType attributeType, bool isMultivalued)
        {
            if (string.IsNullOrWhiteSpace(attributeName))
            {
                throw new ArgumentNullException(attributeName);
            }

            ResourceManagementSchema.ValidateAttributeName(attributeName);

            if (value == null)
            {
                if (comparisonOperator != ComparisonOperator.IsNotPresent && comparisonOperator != ComparisonOperator.IsPresent)
                {
                    throw new InvalidOperationException("An object value is required unless the operator is IsPresent or IsNotPresent");
                }
            }

            this.AttributeName = attributeName;
            this.Operator      = comparisonOperator;
            this.Value         = value;
            this.Negate        = negate;

            this.attributeType = attributeType;
            this.isMultivalued = isMultivalued;

            this.ThrowOnInvalidTypeOperatorCombination();
            this.ThrowOnInvalidNegateCombination();
        }
コード例 #33
0
 private void onDecAttributePoints(AttributeType attributeType)
 {
     changeAttributePoints(attributeType, -1);
 }
コード例 #34
0
        public bool TryGetAttribute(string xaml, string attributeName, AttributeType attributeTypesToCheck, out AttributeType attributeType, out int index, out int length, out string value)
        {
            if (attributeTypesToCheck.HasFlag(AttributeType.Inline))
            {
                var searchText = $"{attributeName}=\"";

                var tbIndex = xaml.IndexOf(searchText, StringComparison.Ordinal);

                if (tbIndex >= 0)
                {
                    var tbEnd = xaml.IndexOf("\"", tbIndex + searchText.Length, StringComparison.Ordinal);

                    attributeType = AttributeType.Inline;
                    index         = tbIndex;
                    length        = tbEnd - tbIndex + 1;
                    value         = xaml.Substring(tbIndex + searchText.Length, tbEnd - tbIndex - searchText.Length);
                    return(true);
                }
            }

            var elementName = xaml.Substring(1, xaml.IndexOfAny(new[] { ' ', '>' }) - 1);

            if (attributeTypesToCheck.HasFlag(AttributeType.Element))
            {
                var searchText = $"<{elementName}.{attributeName}>";

                var startIndex = xaml.IndexOf(searchText, StringComparison.Ordinal);

                if (startIndex > -1)
                {
                    var closingElement = $"</{elementName}.{attributeName}>";
                    var endPos         = xaml.IndexOf(closingElement, startIndex, StringComparison.Ordinal);

                    if (endPos > -1)
                    {
                        attributeType = AttributeType.Element;
                        index         = startIndex;
                        length        = endPos - startIndex + closingElement.Length;
                        value         = xaml.Substring(startIndex + searchText.Length, endPos - startIndex - searchText.Length);
                        return(true);
                    }
                }
            }

            if (attributeTypesToCheck.HasFlag(AttributeType.DefaultValue))
            {
                var endOfOpening   = xaml.IndexOf(">");
                var closingTag     = $"</{elementName}>";
                var startOfClosing = xaml.IndexOf(closingTag, StringComparison.Ordinal);

                if (startOfClosing > 0 && startOfClosing > endOfOpening)
                {
                    var defaultValue = xaml.Substring(endOfOpening + 1, startOfClosing - endOfOpening - 1);

                    if (!string.IsNullOrWhiteSpace(defaultValue) && !defaultValue.TrimStart().StartsWith("<"))
                    {
                        attributeType = AttributeType.DefaultValue;
                        index         = 0;
                        length        = xaml.Length;
                        value         = defaultValue;
                        return(true);
                    }
                }
            }

            attributeType = AttributeType.None;
            index         = -1;
            length        = 0;
            value         = string.Empty;
            return(false);
        }
コード例 #35
0
 public EntityAttribute Get(AttributeType type)
 {
     return(_attributes[type]);
 }
コード例 #36
0
 public void Set(AttributeType type, double value)
 {
     _attributes[type].Set(value);
 }
コード例 #37
0
ファイル: testModelManual2.cs プロジェクト: tmaierhofer/grgen
 public EdgeType_fluffway() : base((int)EdgeTypes.@fluffway)
 {
     AttributeType_numtunnels = new AttributeType("numtunnels", this, AttributeKind.IntegerAttr, null);
 }
コード例 #38
0
        protected void StoreNodes(List <DataSourceNodeBase> nlist, SqlServerDatabaseNode databaseNode)
        {
            NodeService       nsvc   = new NodeService();
            TypeService       tsvc   = new TypeService();
            AttributeService  attsvc = new AttributeService();
            MembershipService msvc   = new MembershipService();

            foreach (DataSourceNodeBase dbnode in nlist)
            {
                string memtypename = null;

                //if there is a non-zero id value, it's already been stored/pulled.
                if (dbnode.NodeIdentity == 0)
                {
                    Node existnode = nsvc.GetByName(dbnode.Name);
                    if (existnode == null)
                    {
                        //hasn't been added yet--create one
                        Type   nclasstype = dbnode.GetType();
                        string ntypename  = null;
                        switch (nclasstype.FullName)
                        {
                        case "SystemMap.Models.Transform.db.sqlserver.SqlServerInstanceNode":
                            ntypename   = "SQL Server";
                            memtypename = null;
                            break;

                        case "SystemMap.Models.Transform.db.sqlserver.SqlServerDatabaseNode":
                            ntypename   = EnumParser.GetValueName(DbClasses.Database);
                            memtypename = null;
                            break;

                        case "SystemMap.Models.Transform.db.sqlserver.SqlServerTableNode":
                            ntypename   = EnumParser.GetValueName(DbClasses.Table);
                            memtypename = ntypename;
                            break;

                        case "SystemMap.Models.Transform.db.sqlserver.SqlServerViewNode":
                            ntypename   = EnumParser.GetValueName(DbClasses.View);
                            memtypename = ntypename;
                            break;

                        case "SystemMap.Models.Transform.db.sqlserver.SqlServerProcedureNode":
                            ntypename   = EnumParser.GetValueName(DbProcesses.StoredProcedue);
                            memtypename = ntypename;
                            break;

                        case "SystemMap.Models.Transform.db.sqlserver.SqlServerFunctionNode":
                            ntypename   = EnumParser.GetValueName(DbProcesses.Function);
                            memtypename = ntypename;
                            break;

                        case "SystemMap.Models.Transform.db.GenericDataSourceNode":
                            ntypename   = "External Reference";
                            memtypename = null;
                            break;

                        default:
                            ntypename   = "General";
                            memtypename = null;
                            break;
                        }
                        NodeType ntype = tsvc.GetNodeType(ntypename, true);
                        existnode = new Node
                        {
                            name        = dbnode.Name,
                            description = ntypename,
                            type        = ntype
                        };
                        try
                        {
                            int nid = nsvc.AddNode(existnode);
                            dbnode.NodeIdentity = nid;
                            if (dbnode.Metadata != null)
                            {
                                foreach (NodeAttribute natt in dbnode.Metadata)
                                {
                                    try
                                    {
                                        AttributeType atype = tsvc.GetAttributeType(natt.type.name, true);
                                        natt.nodeId = dbnode.NodeIdentity;
                                        natt.type   = atype;
                                        attsvc.AddNodeAttribute(natt);
                                    }
                                    catch (Exception ex)
                                    {
                                        Console.WriteLine(ex.StackTrace);
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                    }
                    else
                    {
                        dbnode.NodeIdentity = existnode.id;
                    }
                }
                if (memtypename != null)
                {
                    MembershipType mtype = tsvc.GetMembershipType(memtypename, true);
                    if (mtype != null && databaseNode.NodeIdentity != 0 && dbnode.NodeIdentity != 0)
                    {
                        try
                        {
                            msvc.AddNodeMembership(databaseNode.NodeIdentity, dbnode.NodeIdentity, mtype.typeId);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                    }
                }
            }
        }
コード例 #39
0
ファイル: SceneObject.cs プロジェクト: zhaocy1217/War-Clash
 public long GetAttributeValue(AttributeType at)
 {
     return(AttributeManager[at]);
 }
コード例 #40
0
ファイル: ActorData.cs プロジェクト: AG4W/ChonkyChungus
 public Attribute GetAttribute(AttributeType at)
 {
     return(_attributes[(int)at]);
 }
コード例 #41
0
        /// <summary>
        ///     Add all comments and attributes.
        /// </summary>
        /// <param name="schema">The JsonSchema.</param>
        /// <param name="type">Annotation type to generate.</param>
        public void Populate(JsonSchema schema, AttributeType type)
        {
            // Add description
            if (schema.Description != null)
            {
                AddComment(schema.Description);
            }

            // Add required attribute
            if (schema.Required != null && schema.Required.Value)
            {
                /*switch (type)
                 * {
                 *  case AttributeType.SystemDefault:
                 *      AddAttribute("Required");
                 *      break;
                 *  case AttributeType.JsonDotNet:
                 *      AddAttribute("JsonProperty",
                 *          new CodeAttributeArgument("Required", new CodeSnippetExpression("Required.Always")));
                 *      break;
                 * }*/

                AddAttribute("Required");
            }

            // Number only flags
            if (JsonSchemaUtils.IsNumber(schema))
            {
                if (schema.Minimum != null)
                {
                    if (schema.ExclusiveMinimum != null && schema.ExclusiveMinimum.Value)
                    {
                        AddAttribute("MinValue", (int)schema.Minimum.Value + 1);
                    }
                    else
                    {
                        AddAttribute("MinValue", (int)schema.Minimum.Value);
                    }
                }
                if (schema.Maximum != null)
                {
                    if (schema.ExclusiveMaximum != null && schema.ExclusiveMaximum.Value)
                    {
                        AddAttribute("MaxValue", (int)schema.Maximum.Value - 1);
                    }
                    else
                    {
                        AddAttribute("MaxValue", (int)schema.Maximum.Value);
                    }
                }
            }

            // String only flags
            if (JsonSchemaUtils.IsString(schema))
            {
                var  args = new List <CodeAttributeArgument>();
                bool flag = false;

                if (schema.MaximumLength != null)
                {
                    args.Add(new CodeAttributeArgument(new CodePrimitiveExpression(schema.MaximumLength.Value)));
                    flag = true;
                }

                if (schema.MinimumLength != null)
                {
                    args.Add(new CodeAttributeArgument("MinimumLength",
                                                       new CodePrimitiveExpression(schema.MinimumLength.Value)));
                    flag = true;
                }

                if (flag)
                {
                    AddAttribute("StringLength", args.ToArray());
                }

                if (!String.IsNullOrEmpty(schema.Pattern))
                {
                    AddAttribute("RegularExpression",
                                 new CodeAttributeArgument(new CodeSnippetExpression(string.Format(@"@""{0}""",
                                                                                                   schema.Pattern.SanitizeRegex(true)))));
                }
            }

            // Array only flags
            if (JsonSchemaUtils.IsArray(schema))
            {
                if (schema.MinimumItems != null)
                {
                    AddAttribute("MinLength", schema.MinimumItems.Value);
                }
                if (schema.MaximumItems != null)
                {
                    AddAttribute("MaxLength", schema.MaximumItems.Value);
                }
            }
        }
コード例 #42
0
 public Float2(AttributeType attribute) : base(attribute)
 {
 }
コード例 #43
0
        /// <summary>
        /// Parses attribute from data.
        /// </summary>
        /// <param name="data">SIP message data.</param>
        /// <param name="offset">Offset in data.</param>
        private void ParseAttribute(byte[] data, ref int offset)
        {
            /* RFC 3489 11.2.
             *  Each attribute is TLV encoded, with a 16 bit type, 16 bit length, and variable value:
             *
             *  0                   1                   2                   3
             *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
             +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
             |         Type                  |            Length             |
             +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
             |                             Value                             ....
             +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
             */

            // Type
            AttributeType type = (AttributeType)(data[offset++] << 8 | data[offset++]);

            // Length
            int length = (data[offset++] << 8 | data[offset++]);

            // MAPPED-ADDRESS
            if (type == AttributeType.MappedAddress)
            {
                m_pMappedAddress = ParseEndPoint(data, ref offset);
            }
            // RESPONSE-ADDRESS
            else if (type == AttributeType.ResponseAddress)
            {
                m_pResponseAddress = ParseEndPoint(data, ref offset);
            }
            // CHANGE-REQUEST
            else if (type == AttributeType.ChangeRequest)
            {
                /*
                 *  The CHANGE-REQUEST attribute is used by the client to request that
                 *  the server use a different address and/or port when sending the
                 *  response.  The attribute is 32 bits long, although only two bits (A
                 *  and B) are used:
                 *
                 *   0                   1                   2                   3
                 *   0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
                 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                 |0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 A B 0|
                 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                 *
                 *  The meaning of the flags is:
                 *
                 *  A: This is the "change IP" flag.  If true, it requests the server
                 *     to send the Binding Response with a different IP address than the
                 *     one the Binding Request was received on.
                 *
                 *  B: This is the "change port" flag.  If true, it requests the
                 *     server to send the Binding Response with a different port than the
                 *     one the Binding Request was received on.
                 */

                // Skip 3 bytes
                offset += 3;

                m_pChangeRequest = new STUN_t_ChangeRequest((data[offset] & 4) != 0, (data[offset] & 2) != 0);
                offset++;
            }
            // SOURCE-ADDRESS
            else if (type == AttributeType.SourceAddress)
            {
                m_pSourceAddress = ParseEndPoint(data, ref offset);
            }
            // CHANGED-ADDRESS
            else if (type == AttributeType.ChangedAddress)
            {
                m_pChangedAddress = ParseEndPoint(data, ref offset);
            }
            // USERNAME
            else if (type == AttributeType.Username)
            {
                m_UserName = Encoding.Default.GetString(data, offset, length);
                offset    += length;
            }
            // PASSWORD
            else if (type == AttributeType.Password)
            {
                m_Password = Encoding.Default.GetString(data, offset, length);
                offset    += length;
            }
            // MESSAGE-INTEGRITY
            else if (type == AttributeType.MessageIntegrity)
            {
                offset += length;
            }
            // ERROR-CODE
            else if (type == AttributeType.ErrorCode)
            {
                /* 3489 11.2.9.
                 *  0                   1                   2                   3
                 *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
                 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                 |                   0                     |Class|     Number    |
                 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                 |      Reason Phrase (variable)                                ..
                 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                 */

                int errorCode = (data[offset + 2] & 0x7) * 100 + (data[offset + 3] & 0xFF);

                m_pErrorCode = new STUN_t_ErrorCode(errorCode,
                                                    Encoding.Default.GetString(data, offset + 4, length - 4));
                offset += length;
            }
            // UNKNOWN-ATTRIBUTES
            else if (type == AttributeType.UnknownAttribute)
            {
                offset += length;
            }
            // REFLECTED-FROM
            else if (type == AttributeType.ReflectedFrom)
            {
                m_pReflectedFrom = ParseEndPoint(data, ref offset);
            }
            // XorMappedAddress
            // XorOnly
            // ServerName
            else if (type == AttributeType.ServerName)
            {
                m_ServerName = Encoding.Default.GetString(data, offset, length);
                offset      += length;
            }
            // Unknown
            else
            {
                offset += length;
            }
        }
コード例 #44
0
ファイル: testModelManual2.cs プロジェクト: tmaierhofer/grgen
 public EdgeType_connection() : base((int)EdgeTypes.@connection)
 {
     AttributeType_bandwidth = new AttributeType("bandwidth", this, AttributeKind.IntegerAttr, null);
 }
コード例 #45
0
 public int Add(string name, AttributeType type, int precision, int width)
 {
     return(_table.EditAddField(name, (FieldType)type, precision, width));
 }
コード例 #46
0
        private bool HasAttribute(string xaml, string attribute, AttributeType attributeType = AttributeType.Any)
        {
            var xep = new TestableXamlElementProcessor(ProjectType.Any, new DefaultTestLogger());

            return(xep.TryGetAttribute(xaml, attribute, attributeType, out _, out _, out _, out _));
        }
コード例 #47
0
ファイル: testModelManual2.cs プロジェクト: tmaierhofer/grgen
 public NodeType_Process() : base((int)NodeTypes.@Process)
 {
     AttributeType_name = new AttributeType("name", this, AttributeKind.StringAttr, null);
     AttributeType_val  = new AttributeType("val", this, AttributeKind.IntegerAttr, null);
 }
コード例 #48
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PartitionKey"/> class.
 /// </summary>
 /// <param name="keyName">The name of the key of a table or index.</param>
 /// <param name="keyType">The data type of the key of a table or index.</param>
 public PartitionKey(string keyName, AttributeType keyType = AttributeType.String) : base(keyName, keyType)
 {
 }
コード例 #49
0
    private void changeAttributePoints(AttributeType attributeType, int factor)
    {
        if ((_currentAvaliableAttributePoints - factor) > _originalAvaliableAttributePoints)
        {
            return;
        }

        if ((_currentAvaliableAttributePoints - factor) < 0)
        {
            return;
        }

        switch (attributeType)
        {
        case AttributeType.Air:
            if ((_currentAttributePoints.Air + factor) < _originalAttributePoints.Air)
            {
                return;
            }
            _currentAttributePoints.Air += factor;
            AirPanel.UpdateText(_currentAttributePoints.Air);
            break;

        case AttributeType.Earth:
            if ((_currentAttributePoints.Earth + factor) < _originalAttributePoints.Earth)
            {
                return;
            }
            _currentAttributePoints.Earth += factor;
            EarthPanel.UpdateText(_currentAttributePoints.Earth);
            break;

        case AttributeType.Fire:
            if ((_currentAttributePoints.Fire + factor) < _originalAttributePoints.Fire)
            {
                return;
            }
            _currentAttributePoints.Fire += factor;
            FirePanel.UpdateText(_currentAttributePoints.Fire);
            break;

        case AttributeType.Water:
            if ((_currentAttributePoints.Water + factor) < _originalAttributePoints.Water)
            {
                return;
            }
            _currentAttributePoints.Water += factor;
            WaterPanel.UpdateText(_currentAttributePoints.Water);
            break;

        case AttributeType.Light:
            if ((_currentAttributePoints.Light + factor) < _originalAttributePoints.Light)
            {
                return;
            }
            _currentAttributePoints.Light += factor;
            LightPanel.UpdateText(_currentAttributePoints.Light);
            break;

        case AttributeType.Health:
            if ((_currentAttributePoints.Health + factor) < _originalAttributePoints.Health)
            {
                return;
            }
            _currentAttributePoints.Health += factor;
            HealthPanel.UpdateText(_currentAttributePoints.Health);
            break;

        default:
            break;
        }

        _currentAvaliableAttributePoints -= factor;

        AvaliableAttributePoints.text = _currentAvaliableAttributePoints.ToString();
    }
コード例 #50
0
 /// <summary>
 /// Initializes a new instance of the XPathQuery class
 /// </summary>
 /// <param name="attributeName">The name of the attribute to compare against</param>
 /// <param name="comparisonOperator">The value comparison operator to use</param>
 /// <param name="value">The value to compare against</param>
 /// <param name="negate">Indicates if this query should be negated with the not() operator</param>
 /// <param name="attributeType">The data type of the attribute being queried</param>
 /// <param name="isMultivalued">The multivalued status of the attribute being queried</param>
 /// <remarks>
 /// This constructor can be used when a connection to the resource management service not available. The attribute type and multivalued status are not validated against the schema
 /// </remarks>
 public XPathQuery(string attributeName, ComparisonOperator comparisonOperator, object value, bool negate, AttributeType attributeType, bool isMultivalued)
 {
     this.SetupBuilder(attributeName, comparisonOperator, value, negate, attributeType, isMultivalued);
 }
コード例 #51
0
        protected void CheckForHardCodedAttribute(string elementName, string attributeName, AttributeType types, string descriptionFormat, string xamlElement, ITextSnapshot snapshot, int offset, bool uidExists, string uidValue, Guid elementIdentifier, List <IRapidXamlAdornmentTag> tags)
        {
            if (this.TryGetAttribute(xamlElement, attributeName, types, out AttributeType foundAttributeType, out int tbIndex, out int length, out string value))
            {
                if (!string.IsNullOrWhiteSpace(value) && char.IsLetterOrDigit(value[0]))
                {
                    var line = snapshot.GetLineFromPosition(offset + tbIndex);
                    var col  = offset + tbIndex - line.Start.Position;

                    tags.Add(new HardCodedStringTag(new Span(offset + tbIndex, length), snapshot, line.LineNumber, col, elementName, attributeName)
                    {
                        AttributeType = foundAttributeType,
                        Value         = value,
                        Description   = descriptionFormat.WithParams(value),
                        UidExists     = uidExists,
                        UidValue      = uidValue,
                        ElementGuid   = elementIdentifier,
                    });
                }
            }
        }
コード例 #52
0
 public float this[AttributeType type] => sumAttributes[type];
        public bool FetchObjectToBeShownAsGraph(Sequence seq, out object toBeShownAsGraph, out AttributeType attrType)
        {
            do
            {
                Console.WriteLine("Enter name of variable or attribute access to show as graph (just enter for abort): ");
                Console.WriteLine("Examples: \"v\", \"v.a\", \"@(\"$0\").a\" ");
                String str = Console.ReadLine();
                if (str.Length == 0)
                {
                    toBeShownAsGraph = null;
                    attrType         = null;
                    return(true);
                }

                if (str.StartsWith("@"))
                {
                    // graph element by name
                    string        attributeName;
                    IGraphElement elem = ParseAccessByName(str, out attributeName);
                    if (elem == null)
                    {
                        Console.WriteLine("Can't parse graph access / unknown graph element: " + str);
                        continue;
                    }
                    if (attributeName == null)
                    {
                        Console.WriteLine("The result of a graph access is a node or edge, you must access an attribute: " + str);
                        continue;
                    }
                    attrType = elem.Type.GetAttributeType(attributeName);
                    if (attrType == null)
                    {
                        Console.WriteLine("Unknown attribute: " + attributeName);
                        continue;
                    }
                    object attribute = elem.GetAttribute(attributeName);
                    if (attribute == null)
                    {
                        Console.WriteLine("Null-valued attribute: " + attributeName);
                        continue;
                    }

                    toBeShownAsGraph = attribute;
                    return(false);
                }
                else
                {
                    // variable
                    string attributeName;
                    object value = ParseVariable(str, seq, out attributeName);
                    if (value == null)
                    {
                        Console.WriteLine("Can't parse variable / unknown variable / null-valued variable: " + str);
                        continue;
                    }

                    if (attributeName != null)
                    {
                        if (!(value is IGraphElement))
                        {
                            Console.WriteLine("Can't access attribute, the variable value is not a graph element: " + str);
                            continue;
                        }
                        IGraphElement elem = (IGraphElement)value;
                        attrType = elem.Type.GetAttributeType(attributeName);
                        if (attrType == null)
                        {
                            Console.WriteLine("Unknown attribute: " + attributeName);
                            continue;
                        }
                        object attribute = elem.GetAttribute(attributeName);
                        if (attribute == null)
                        {
                            Console.WriteLine("Null-valued attribute: " + attributeName);
                            continue;
                        }

                        toBeShownAsGraph = attribute;
                        return(false);
                    }
                    else
                    {
                        attrType         = null;
                        toBeShownAsGraph = value;
                        return(false);
                    }
                }
            }while(true);
        }
コード例 #54
0
ファイル: testModelManual2.cs プロジェクト: tmaierhofer/grgen
 public EdgeType_slowway() : base((int)EdgeTypes.@slowway)
 {
     AttributeType_slowspeed = new AttributeType("slowspeed", this, AttributeKind.IntegerAttr, null);
 }
コード例 #55
0
 private void onIncAttributePoints(AttributeType attributeType)
 {
     changeAttributePoints(attributeType, +1);
 }
コード例 #56
0
ファイル: testModelManual2.cs プロジェクト: tmaierhofer/grgen
 public EdgeType_speedcon() : base((int)EdgeTypes.@speedcon)
 {
     AttributeType_classkind = new AttributeType("classkind", this, AttributeKind.StringAttr, null);
 }
コード例 #57
0
        public override ICriterion VisitFieldPredicate(FieldPredicateExpression node)
        {
            var fieldName      = node.SelectorExpression.FieldName;
            var valueKey       = node.SelectorExpression.ValueKey;
            var fieldValue     = node.ValueExpression.Value;
            var fieldValueType = fieldValue != null?fieldValue.GetType() : typeof(string);

            switch (fieldName.ToLowerInvariant())
            {
            case "id":
                Guid idValue = GetIdValue(node);

                switch (node.ValueExpression.ClauseType)
                {
                case ValuePredicateType.Equal:
                    _discoveredRequiredNodeIds.Add(idValue);
                    return(Restrictions.Eq(Projections.Property(() => version.Node.Id), idValue));

                case ValuePredicateType.NotEqual:
                    _negatingNodeIdsExist = true;
                    return(!Restrictions.Eq(Projections.Property(() => version.Node.Id), idValue));

                default:
                    throw new InvalidOperationException(
                              "Cannot query an item by id by any other operator than == or !=");
                }

            case "system-internal-selected-template":
                //TODO Pending property editors getting involved in query modification prior to being passed to hive provider,
                //manually check for queries against a template here
                if (valueKey == "TemplateId" && fieldValue != null)
                {
                    var tryParseResult = HiveId.TryParse(fieldValue.ToString());
                    if (!tryParseResult.Success || tryParseResult.Result.ProviderGroupRoot == null || tryParseResult.Result.ProviderId == null ||
                        (tryParseResult.Result.ProviderGroupRoot.AbsoluteUri != "storage://" && tryParseResult.Result.ProviderId != "templates"))
                    {
                        var normalisedFieldValue = "/" + fieldValue.ToString().TrimStart("/").TrimEnd(".") + ".";
                        // Need to convert the value into the serialized form that a HiveId would use
                        var newValue = new HiveId("storage", "templates", new HiveIdValue(normalisedFieldValue)).ToString(HiveIdFormatStyle.UriSafe);
                        fieldValue = newValue;
                    }
                    else
                    {
                        fieldValue = tryParseResult.Result.ToString(HiveIdFormatStyle.UriSafe);
                    }
                }
                break;
            }

            // First look up the types of the main field
            AttributeDefinition defAlias  = null;
            AttributeType       typeAlias = null;
            var attributeType             = _activeSession.NhSession.QueryOver <AttributeDefinition>(() => defAlias)
                                            .JoinAlias(() => defAlias.AttributeType, () => typeAlias)
                                            .Where(() => defAlias.Alias == fieldName)
                                            .Select(x => typeAlias.PersistenceTypeProvider)
                                            .List <string>();

            foreach (var type in attributeType)
            {
                var typeName = type;
                if (_typesAlreadyEstablished.Contains(typeName))
                {
                    continue;
                }
                try
                {
                    _typesAlreadyEstablished.Add(typeName);
                    var persisterType = Type.GetType(typeName, false);
                    if (persisterType != null)
                    {
                        var persisterInstance = Activator.CreateInstance(persisterType) as IAttributeSerializationDefinition;
                        if (persisterInstance != null && !_typesToQuery.Contains(persisterInstance.DataSerializationType))
                        {
                            _typesToQuery.Add(persisterInstance.DataSerializationType);
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.Error <NhCriteriaVisitor>("Error while trying to decide which value-tables to join & query", ex);
                    throw;
                }
            }

            // U5-789
            // Workaround pending a better check of what data is actually saved
            // An issue arose because previous data had been saved in long-string,
            // but the datatype changed to be just string, therefore only string was
            // being queried despite all the data residing still in long-string
            if (_typesToQuery.Contains(DataSerializationTypes.String) && !_typesToQuery.Contains(DataSerializationTypes.LongString))
            {
                _typesToQuery.Add(DataSerializationTypes.LongString);
            }

            //NodeVersion aliasNodeVersion = null;
            //Attribute aliasAttribute = null;
            //AttributeDefinition aliasAttributeDefinition = null;
            //AttributeStringValue aliasStringValue = null;
            //AttributeLongStringValue aliasLongStringValue = null;
            //AttributeIntegerValue aliasIntegerValue = null;
            //AttributeDecimalValue aliasDecimalValue = null;
            //NodeRelation aliasNodeRelation = null;
            //AttributeDateValue aliasDateValue = null;

            //QueryOver<NodeVersion, AttributeDefinition> queryExtender = QueryOver.Of<NodeVersion>(() => aliasNodeVersion)
            //    .JoinQueryOver<Attribute>(() => aliasNodeVersion.Attributes, () => aliasAttribute)
            //    .JoinQueryOver<AttributeDefinition>(() => aliasAttribute.AttributeDefinition, () => aliasAttributeDefinition);

            int numberOfMatchesEvaluated         = 0;
            AbstractCriterion restrictionBuilder = null;

            foreach (var dataSerializationTypese in _typesToQuery.Distinct())
            {
                AbstractCriterion           restriction        = null;
                Expression <Func <object> > propertyExpression = null;
                Expression <Func <object> > subkeyExpression   = null;
                List <ValuePredicateType>   validClauseTypes   = null;
                var useLikeMatchForStrings = false;
                switch (dataSerializationTypese)
                {
                case DataSerializationTypes.SmallInt:
                case DataSerializationTypes.LargeInt:
                case DataSerializationTypes.Boolean:
                    propertyExpression = () => integerVal.Value;
                    subkeyExpression   = () => integerVal.ValueKey;
                    validClauseTypes   = new List <ValuePredicateType>()
                    {
                        ValuePredicateType.Equal,
                        ValuePredicateType.GreaterThan,
                        ValuePredicateType.GreaterThanOrEqual,
                        ValuePredicateType.LessThan,
                        ValuePredicateType.LessThanOrEqual,
                        ValuePredicateType.NotEqual
                    };
                    break;

                case DataSerializationTypes.Decimal:
                    propertyExpression = () => decimalVal.Value;
                    subkeyExpression   = () => decimalVal.ValueKey;
                    validClauseTypes   = new List <ValuePredicateType>()
                    {
                        ValuePredicateType.Equal,
                        ValuePredicateType.GreaterThan,
                        ValuePredicateType.GreaterThanOrEqual,
                        ValuePredicateType.LessThan,
                        ValuePredicateType.LessThanOrEqual,
                        ValuePredicateType.NotEqual
                    };
                    break;

                case DataSerializationTypes.String:
                    propertyExpression = () => stringVal.Value;
                    subkeyExpression   = () => stringVal.ValueKey;
                    validClauseTypes   = new List <ValuePredicateType>()
                    {
                        ValuePredicateType.Equal,
                        ValuePredicateType.NotEqual,
                        ValuePredicateType.Contains,
                        ValuePredicateType.StartsWith,
                        ValuePredicateType.EndsWith,
                        ValuePredicateType.MatchesWildcard
                    };
                    break;

                case DataSerializationTypes.LongString:
                    propertyExpression     = () => longStrVal.Value;
                    subkeyExpression       = () => longStrVal.ValueKey;
                    useLikeMatchForStrings = true;
                    validClauseTypes       = new List <ValuePredicateType>()
                    {
                        ValuePredicateType.Equal,
                        ValuePredicateType.NotEqual,
                        ValuePredicateType.Contains,
                        ValuePredicateType.StartsWith,
                        ValuePredicateType.EndsWith,
                        ValuePredicateType.MatchesWildcard
                    };
                    break;

                case DataSerializationTypes.Date:
                    propertyExpression = () => dateVal.Value;
                    subkeyExpression   = () => dateVal.ValueKey;
                    validClauseTypes   = new List <ValuePredicateType>()
                    {
                        ValuePredicateType.Equal,
                        ValuePredicateType.GreaterThan,
                        ValuePredicateType.GreaterThanOrEqual,
                        ValuePredicateType.LessThan,
                        ValuePredicateType.LessThanOrEqual,
                        ValuePredicateType.NotEqual,
                        ValuePredicateType.Empty
                    };
                    break;
                }

                if (!validClauseTypes.Contains(node.ValueExpression.ClauseType))
                {
                    throw new InvalidOperationException("A field of type {0} cannot be queried with operator {1}".InvariantFormat(dataSerializationTypese.ToString(), node.ValueExpression.ClauseType.ToString()));
                }

                switch (node.ValueExpression.ClauseType)
                {
                case ValuePredicateType.Equal:
                    restriction = GetRestrictionEq(fieldValue, useLikeMatchForStrings, propertyExpression, subkeyExpression, valueKey);
                    break;

                case ValuePredicateType.NotEqual:
                    restriction = !GetRestrictionEq(fieldValue, useLikeMatchForStrings, propertyExpression);
                    break;

                case ValuePredicateType.LessThan:
                    restriction = GetRestrictionLt(fieldValue, propertyExpression);
                    break;

                case ValuePredicateType.LessThanOrEqual:
                    restriction = GetRestrictionLtEq(fieldValue, propertyExpression);
                    break;

                case ValuePredicateType.GreaterThan:
                    restriction = GetRestrictionGt(fieldValue, propertyExpression);
                    break;

                case ValuePredicateType.GreaterThanOrEqual:
                    restriction = GetRestrictionGtEq(fieldValue, propertyExpression);
                    break;

                case ValuePredicateType.Contains:
                    restriction = GetRestrictionContains(fieldValue, propertyExpression);
                    break;

                case ValuePredicateType.StartsWith:
                    restriction = GetRestrictionStarts(fieldValue, propertyExpression);
                    break;

                case ValuePredicateType.EndsWith:
                    restriction = GetRestrictionEnds(fieldValue, propertyExpression);
                    break;
                }

                if (restriction != null)
                {
                    if (numberOfMatchesEvaluated == 0)
                    {
                        restrictionBuilder = restriction;
                        numberOfMatchesEvaluated++;
                    }
                    else
                    {
                        restrictionBuilder = Restrictions.Or(restriction, restrictionBuilder);
                    }
                }
            }

            var fieldNameRestriction = Restrictions.Eq(Projections.Property(() => def.Alias), fieldName);

            if (restrictionBuilder != null)
            {
                restrictionBuilder = Restrictions.And(restrictionBuilder, fieldNameRestriction);
            }
            else
            {
                restrictionBuilder = fieldNameRestriction;
            }

            return(restrictionBuilder);
        }
コード例 #58
0
 public TextAttribute(AttributeType attributeType, string value)
     : base(attributeType, value)
 {
 }
コード例 #59
0
 public SpecialAttribute(AttributeType type, int value)
 {
     this.attributeType  = type;
     this.attributeValue = value;
 }
コード例 #60
0
 public AttributeSelect(string name, AttributeType attributeType, AttributeDataType dataType)
     : base(name, attributeType, dataType)
 {
 }