public override bool IsMatch(AttributeInfo attributeInfo)
            {
                INamedTypeSymbol attributeClass = attributeInfo.AttributeClass;

                if (AttributeNames.Contains(attributeClass))
                {
                    return(false);
                }

                ISymbol symbol = attributeInfo.Target;

                if (symbol.IsKind(SymbolKind.NamedType) &&
                    attributeClass.HasMetadataName(_defaultMemberAttribute))
                {
                    var namedType = (INamedTypeSymbol)symbol;

                    if (namedType.GetMembers().Any(f => f.IsKind(SymbolKind.Property) && ((IPropertySymbol)f).IsIndexer))
                    {
                        return(false);
                    }
                }
#if DEBUG
                Debug.Assert(
                    attributeClass.MetadataName == "FooAttribute" ||
                    attributeClass.MetadataName == "BarAttribute" ||
                    _knownVisibleAttributes.Contains(attributeClass),
                    attributeClass.ToDisplayString());
#endif
                return(true);
            }
Example #2
0
        public string GetTransmissionInformation(long datasetVersionId, TransmissionType type, string name,
                                                 AttributeNames returnType = AttributeNames.value)
        {
            DatasetVersion    datasetVersion    = this.GetUnitOfWork().GetReadOnlyRepository <DatasetVersion>().Get(datasetVersionId);
            Dataset           dataset           = this.GetUnitOfWork().GetReadOnlyRepository <Dataset>().Get(datasetVersion.Dataset.Id);
            MetadataStructure metadataStructure = this.GetUnitOfWork().GetReadOnlyRepository <MetadataStructure>().Get(dataset.MetadataStructure.Id);

            // get MetadataStructure
            if (datasetVersion != null && dataset != null &&
                metadataStructure != null && datasetVersion.Metadata != null && metadataStructure.Extra != null)
            {
                XDocument xDoc = XmlUtility.ToXDocument((XmlDocument)datasetVersion.Dataset.MetadataStructure.Extra);

                Dictionary <string, string> queryDic = new Dictionary <string, string>();
                queryDic.Add(AttributeNames.name.ToString(), name);
                queryDic.Add(AttributeNames.type.ToString(), type.ToString());

                IEnumerable <XElement> temp = XmlUtility.GetXElementsByAttribute(nodeNames.convertRef.ToString(), queryDic, xDoc);

                string value = temp.First().Attribute(returnType.ToString()).Value;

                return(value);
            }
            return(string.Empty);
        }
        private void Add(string name, AttributeMetadata value)
        {
            Dictionary.Add(name.ToLowerInvariant(), value);

            AttributeNames.Add(name);
            Values.Add(value);
        }
Example #4
0
 public Skill(String name, Difficulty diff, AttributeNames type, int tech, int points)
 {
     Name      = name;
     Diff      = diff;
     SkillType = type;
     TechLevel = tech;
     Points    = points;
 }
Example #5
0
        private Agent CreateAgent(int index)
        {
            var attributeCount = _random.Next(0, AttributeNames.Length);
            var attributes     = AttributeNames
                                 .TakeRandom(attributeCount)
                                 .Select(CreateAttribute);

            return(new Agent(attributes));
        }
        public void Parse()
        {
            ParseKey();
            //ParseKey(new Manager().GetKey(DataSourceId, SreKeyTypes.CSharpCodeOutputWriter.ToString()));

            AttributeNames               = AttributeNames.DistinctEx();
            SystemAttributeNames         = SystemAttributeNames.DistinctEx();
            ProcessVariablesIncorrectWay = ProcessVariablesIncorrectWay.DistinctEx();
            ProcessVariables             = ProcessVariables.DistinctEx();
        }
 public void AddSkill(AttributeNames aN, Skill skill)
 {
     try
     {
         skillsDict[aN].Add(skill);
     }
     catch (KeyNotFoundException)
     {
         Console.WriteLine("Key not found");
     }
 }
 //if improper key is given null result - check
 public Skill GetSkill(AttributeNames aN, int listPos)
 {
     if (skillsDict.TryGetValue(aN, out List <Skill> skillList))
     {
         return(skillList[listPos]);
     }
     else
     {
     }
     return(null);
 }
Example #9
0
        private string GetString(XElement element, AttributeNames attributeIndex)
        {
            var attributeName = Serialization.AttributeNameList[(int)attributeIndex];
            var attribute     = element.Attribute(attributeName);

            if (attribute != null)
            {
                return(stringTable.Intern(attribute.Value));
            }

            return(null);
        }
 public List <Skill> GetSkills(AttributeNames aN)
 {
     if (skillsDict.TryGetValue(aN, out List <Skill> skillList))
     {
         return(skillList);
     }
     else
     {
         Console.WriteLine("Key Not Found");
         throw new KeyNotFoundException();
     }
 }
        private int GetInteger(AttributeNames attributeIndex)
        {
            var text = GetString(attributeIndex);

            if (text == null)
            {
                return(0);
            }

            int result;

            int.TryParse(text, out result);
            return(result);
        }
        private DateTime GetDateTime(AttributeNames attributeIndex)
        {
            var text = GetString(attributeIndex);

            if (text == null)
            {
                return(default(DateTime));
            }

            DateTime result;

            DateTime.TryParse(text, out result);
            return(result);
        }
        private bool GetBoolean(AttributeNames attributeIndex)
        {
            var text = GetString(attributeIndex);

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

            bool result;

            bool.TryParse(text, out result);
            return(result);
        }
        private string GetString(AttributeNames attributeIndex)
        {
            var attributeName = Serialization.AttributeLocalNameList[(int)attributeIndex];

            for (int i = 0; i < attributes.Count; i++)
            {
                if (attributeName == attributes[i].Key)
                {
                    return(attributes[i].Value);
                }
            }

            return(null);
        }
Example #15
0
        private void AddAttributes()
        {
            int   points     = pointDistribution.AttributePoints;
            Array enumValues = Enum.GetValues(typeof(AttributeNames));

            while (points > 0)
            {
                AttributeNames attributeName = (AttributeNames)Enum.Parse(typeof(AttributeNames), rand.Next(enumValues.Length).ToString());
                points -= npc.GetAttribute(attributeName).Scale;
                if (points > 0)
                {
                    npc.SetAttribute(attributeName, IncreaseAttributeLevel(attributeName));
                }
            }
        }
Example #16
0
        public void Parse()
        {
            using (StringReader reader = new StringReader(RuleAsXaml))
            {
                string line = string.Empty;
                do
                {
                    line = reader.ReadLine();
                    if (line != null)
                    {
                        Collect(line);
                    }
                } while (line != null);
            }

            AttributeNames               = AttributeNames.DistinctEx();
            SystemAttributeNames         = SystemAttributeNames.DistinctEx();
            ProcessVariablesIncorrectWay = ProcessVariablesIncorrectWay.DistinctEx();
            ProcessVariables             = ProcessVariables.DistinctEx();
        }
        private void Collect(string line)
        {
            string attributeName = Extract(line, "Data.CurrentRow.Columns(&quot;", "&quot;");

            if (!string.IsNullOrEmpty(attributeName))
            {
                AttributeNames.Add(attributeName);
            }

            string systemAttributeName = Extract(line, "Data.CurrentRow.ColumnsSystem(&quot;", "&quot;");

            if (!string.IsNullOrEmpty(systemAttributeName))
            {
                SystemAttributeNames.Add(systemAttributeName);
            }

            string processVariableName = Extract(line, "Job.ProcessVariables(\"", "\"");

            if (!string.IsNullOrEmpty(processVariableName))
            {
                ProcessVariablesIncorrectWay.Add(processVariableName);
            }

            processVariableName = Extract(line, "Job.ProcessVariables(&quot;", "&quot;");
            if (!string.IsNullOrEmpty(processVariableName))
            {
                ProcessVariablesIncorrectWay.Add(processVariableName);
            }

            processVariableName = Extract(line, "Job.GetProcessVariableValue(\"", "\"");
            if (!string.IsNullOrEmpty(processVariableName))
            {
                ProcessVariables.Add(processVariableName);
            }

            processVariableName = Extract(line, "Job.GetProcessVariableValue(&quot;", "&quot;");
            if (!string.IsNullOrEmpty(processVariableName))
            {
                ProcessVariables.Add(processVariableName);
            }
        }
Example #18
0
        /// <summary>
        /// Loads all data. Should be positioned on the start
        /// if the second data hunk.
        /// </summary>
        /// <param name="dataReader"></param>
        public ExecutableData(IDataReader dataReader)
        {
            // TODO: For now we search the offset of the filelist manually
            //       until we decode all of the data.
            dataReader.Position = (int)dataReader.FindString("0Map_data.amb", 0) - 184;

            // TODO ...
            FileList   = new FileList(dataReader);
            WorldNames = new WorldNames(dataReader);
            Messages   = new Messages(dataReader);
            if (dataReader.ReadDword() != 0)
            {
                throw new AmbermoonException(ExceptionScope.Data, "Invalid executable data.");
            }
            AutomapNames   = new AutomapNames(dataReader);
            OptionNames    = new OptionNames(dataReader);
            SongNames      = new SongNames(dataReader);
            SpellTypeNames = new SpellTypeNames(dataReader);
            SpellNames     = new SpellNames(dataReader);
            LanguageNames  = new LanguageNames(dataReader);
            ClassNames     = new ClassNames(dataReader);
            RaceNames      = new RaceNames(dataReader);
            AbilityNames   = new AbilityNames(dataReader);
            AttributeNames = new AttributeNames(dataReader);
            AbilityNames.AddShortNames(dataReader);
            AttributeNames.AddShortNames(dataReader);
            ItemTypeNames = new ItemTypeNames(dataReader);
            AilmentNames  = new AilmentNames(dataReader);
            UITexts       = new UITexts(dataReader);

            // TODO: There is a bunch of binary data (gfx maybe?)

            // TODO: Then finally the item data comes ...

            // TODO ...
        }
Example #19
0
        /// <summary>
        /// Sets a given core Identity attribute with a given value in Identity
        /// </summary>
        /// <param name="loginName">The login name for the user you want to set attribute for</param>
        /// <param name="cookie">The users cookie</param>
        /// <param name="attributeName">The name of the attribute you want to change</param>
        /// <param name="value">The value you want to set it to</param>
        /// <returns>True if set ok, false if not</returns>
        public static bool SetIdentityAttribute(string loginName, string cookie, AttributeNames attributeName, string value)
        {
            List<Cookie> cookies = new List<Cookie>();
            cookies.Add(new Cookie("IDENTITY", cookie, "/", _identityCookieDomain));
            Dictionary<string, string> reqParams = new Dictionary<string, string>();

            string identityAttrib = "";
            if (attributeName == AttributeNames.UserName)
            {
                identityAttrib = _wrUserName;
            }
            else if (attributeName == AttributeNames.DisplayName)
            {
                identityAttrib = _wrdisplayName;
            }
            else if (attributeName == AttributeNames.Email)
            {
                identityAttrib = _wremail;
            }
            else if (attributeName == AttributeNames.LegacySSOID)
            {
                identityAttrib = _wrLegacySSOID;
            }
            else if (attributeName == AttributeNames.FirstName)
            {
                identityAttrib = _wrFirstName;
            }
            else if (attributeName == AttributeNames.LastName)
            {
                identityAttrib = _wrLastName;
            }
            else if (attributeName == AttributeNames.GuardianAgreedTermsAndConditions)
            {
                identityAttrib = _wrGuardianAcceptedFlag;
            }
            else if (attributeName == AttributeNames.GuardianEmail)
            {
                identityAttrib = _wrGuardianEmail;
            }
            else if (attributeName == AttributeNames.GuardianEmailConfirmed)
            {
                identityAttrib = _wrGuardianEmailConfirmed;
            }
            else
            {
                return false;
            }

            reqParams.Add(identityAttrib, value);
            HttpWebResponse response = CallIdentityRestAPI(string.Format("users/{0}/attributes", loginName), reqParams, cookies, RequestVerb.PUT);
            bool ok = true;
            if (response.StatusCode != HttpStatusCode.Accepted)
            {
                Assert.Fail("Failed to set the users attribute : " + identityAttrib + " with value : " + value);
                ok = false;
            }
            response.Close();
            Thread.Sleep(5000);
            return ok;
        }
Example #20
0
        private void Collect(string line)
        {
            List <string> activityNames = new List <string>(new string[] { "AddError", "AddOrUpdateProcessVariable", "AssignAttribute", "WriteTraceToCurrentRow", "PreValidationFailed", "DuplicateCheck",
                                                                           "RestApiCall", "Lookup", "PersistVariable", "GetPersistVariable", "DeletePersistVariable", "ExecuteNonQuery" });
            string startedWith        = "<{0}:{1}";
            string whatTypeOfActivity = string.Empty;

            foreach (string activityName in activityNames)
            {
                if (line.Trim().StartsWith(string.Format(startedWith, prefix, activityName)))
                {
                    whatTypeOfActivity = activityName;
                    break;
                }
            }

            //if (line.Trim().StartsWith("    <srs:AssignAttribute"))
            //    Debugger.Break();

            string attributeName = Extract(line, "Data.CurrentRow.Columns(&quot;", "&quot;");

            //if (attributeName.Contains("BookingCustomerId"))
            //    Debugger.Break();

            if (!string.IsNullOrEmpty(attributeName))
            {
                AttributeNames.Add(attributeName);
            }

            string systemAttributeName = Extract(line, "Data.CurrentRow.ColumnsSystem(&quot;", "&quot;");

            if (!string.IsNullOrEmpty(systemAttributeName))
            {
                SystemAttributeNames.Add(systemAttributeName);
            }

            string processVariableName = Extract(line, "Job.ProcessVariables(\"", "\"");

            if (!string.IsNullOrEmpty(processVariableName))
            {
                ProcessVariablesIncorrectWay.Add(processVariableName);
            }

            processVariableName = Extract(line, "Job.ProcessVariables(&quot;", "&quot;");
            if (!string.IsNullOrEmpty(processVariableName))
            {
                ProcessVariablesIncorrectWay.Add(processVariableName);
            }

            processVariableName = Extract(line, "Job.GetProcessVariableValue(\"", "\"");
            if (!string.IsNullOrEmpty(processVariableName))
            {
                ProcessVariables.Add(processVariableName);
            }

            processVariableName = Extract(line, "Job.GetProcessVariableValue(&quot;", "&quot;");
            if (!string.IsNullOrEmpty(processVariableName))
            {
                ProcessVariables.Add(processVariableName);
            }

            if (whatTypeOfActivity == "Lookup")
            {
                string columName     = Extract(line, "ColumnName=\"", "\"");
                string isSytemColumn = Extract(line, "IsSystemColumn=\"", "\"");
                if (!string.IsNullOrEmpty(columName))
                {
                    if (isSytemColumn.ToLower() == "true")
                    {
                        SystemAttributeNames.Add(columName);
                    }
                    else
                    {
                        AttributeNames.Add(columName);
                    }
                }
            }
        }
Example #21
0
 private int GetInteger(XElement element, AttributeNames attributeIndex)
 {
     return(Serialization.GetInteger(GetString(element, attributeIndex)));
 }
 private int GetInteger(AttributeNames attributeIndex)
 {
     return(Serialization.GetInteger(GetString(attributeIndex)));
 }
Example #23
0
 private bool GetBoolean(XElement element, AttributeNames attributeIndex)
 {
     return(Serialization.GetBoolean(GetString(element, attributeIndex)));
 }
Example #24
0
 private DateTime GetDateTime(XElement element, AttributeNames attributeIndex)
 {
     return(Serialization.GetDateTime(GetString(element, attributeIndex)));
 }
Example #25
0
 public Attribute GetAttribute(AttributeNames aN)
 {
     return(attributes[(int)aN]);
 }
Example #26
0
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var sId = this.AsyncDialog("Id", ag =>
            {
                return(this.DialogValue("none"));
            });
            var subEntity = Utility.CMS.ObjectEntity <UMC.Data.Entities.Subject>();

            subEntity.Where.And().Equal(new Subject {
                Id = Utility.Guid(sId, true)
            });

            var sub  = subEntity.Single();
            var user = UMC.Security.Identity.Current;

            if (user.IsAuthenticated == false)
            {
                response.Redirect(POSModel.Account, POSCommand.Login);
            }
            var attr = new AttributeNames(request.Ticket);

            if (sub.user_id == user.Id)
            {
                this.Prompt("此图文是你自己的,不用复制");
            }
            var Score = ((sub.Score ?? 0) + 1);

            if (String.Equals("markdown", sub.ContentType, StringComparison.CurrentCultureIgnoreCase))
            {
                this.Prompt("此图文是Markdown格式,不支持复制编辑");
            }
            if ((sub.soure_id ?? Guid.Empty) != Guid.Empty)
            {
                this.AsyncDialog("Confirm", g => new Web.UIConfirmDialog("此图文来源于复制,你需要去原图文才能复制,点击确认将去原文"));

                this.Context.Send(new UISectionBuilder(request.Model, request.Command, new UMC.Web.WebMeta().Put("Id", sub.soure_id))

                                  .Builder(), true);
            }

            this.AsyncDialog("Confirm", g => new Web.UIConfirmDialog(String.Format("复制此图文需要扣减 {0} 积分", Score)));//,你需要去原图文才能复制,点击确认将去原文"));



            var memberEntity = UMC.Retail.Entities.Utility.Database.ObjectEntity <UMC.Retail.Entities.VIPMember>();
            var member       = memberEntity.Where.And().Equal(new VIPMember {
                Id = user.Id.Value
            }).Entities.Single();

            if (member == null || member.Points < Score)
            {
                this.Context.Send(new UISectionBuilder(request.Model, "UIData", new UMC.Web.WebMeta().Put("Id", "Subject.Points"))

                                  .Builder(), true);
            }

            VIPUtility.MemberLog(attr.StoreId.Value, attr.Ticket.POSCode, sub.Id.Value, 0 - Score, String.Format("复制图文 {0}", sub.Title), MemberLogType.ExChange, user.Id.Value);

            if (sub.AppId.HasValue)
            {
                VIPUtility.MemberLog(attr.StoreId.Value, attr.Ticket.POSCode, sub.Id.Value, 1, String.Format("复制图文 {0}", sub.Title), MemberLogType.Royalty, sub.AppId.Value);
            }
            if (sub.user_id.HasValue && Score - 1 > 0)
            {
                VIPUtility.MemberLog(attr.StoreId.Value, attr.Ticket.POSCode, sub.Id.Value, Score - 1, String.Format("复制图文 {0}", sub.Title), MemberLogType.Sales, sub.AppId.Value);
            }
            sub.category_id = null;
            sub.Favs        = 0;
            sub.Look        = 0;
            sub.Reply       = 0;
            sub.Status      = -1;
            sub.SubmitTime  = null;
            sub.soure_id    = sub.Id;
            sub.AppId       = null;
            sub.LastDate    = DateTime.Now;
            sub.ReleaseDate = DateTime.Now;
            sub.Poster      = user.Alias;
            var newId = Guid.NewGuid();

            sub.user_id = user.Id;

            var config   = Data.JSON.Deserialize <Hashtable>(sub.ConfigXml) ?? new Hashtable();
            var imageKey = config["images"] as Hashtable ?? new Hashtable();

            sub.ConfigXml = Data.JSON.Serialize(new UMC.Web.WebMeta().Put("images", imageKey));

            var pictureEntity = UMC.Data.Database.Instance().ObjectEntity <UMC.Data.Entities.Picture>();

            pictureEntity.Where.And().GreaterEqual(new Data.Entities.Picture {
                Seq = 0
            });
            var images = new List <Picture>();

            pictureEntity.Where
            .And().In(new Data.Entities.Picture
            {
                group_id = sub.Id
            }).Entities.Query(dr =>
            {
                images.Add(dr);
                dr.group_id = newId;
            });
            var webr = UMC.Data.WebResource.Instance();

            foreach (var r in images)
            {
                var rpath1 = String.Format("{2}{1}/{0}/0.jpg", "1", newId, UMC.Data.WebResource.ImageResource);
                var rpath3 = String.Format("{2}{1}/{0}/0.jpg", "1", sub.Id, UMC.Data.WebResource.ImageResource);
                webr.CopyResolveUrl(rpath3, rpath1);
            }
            if (images.Count > 0)
            {
                pictureEntity.Insert(images.ToArray());
            }
            sub.Id = newId;
            subEntity.Insert(sub);
            response.Redirect(request.Model, "EditUI", sub.Id.ToString());
        }
Example #27
0
 public void SetAttribute(AttributeNames aN, int points)
 {
     Points += points;
     attributes[(int)aN].Points = points;
 }
Example #28
0
        /// <summary>
        /// returns a List of all transmission nodes in the metadataStructure
        /// </summary>
        /// <param name="metadatastrutcureId"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public IEnumerable <string> GetAllTransmissionInformationFromMetadataStructure(long metadataStructureId, TransmissionType type,
                                                                                       AttributeNames returnType = AttributeNames.value)
        {
            MetadataStructure metadataStructure = this.GetUnitOfWork().GetReadOnlyRepository <MetadataStructure>().Get(metadataStructureId);

            List <string> tmpList = new List <string>();

            try
            {
                XDocument xDoc = XmlUtility.ToXDocument((XmlDocument)metadataStructure.Extra);
                IEnumerable <XElement> temp = XmlUtility.GetXElementsByAttribute(nodeNames.convertRef.ToString(), AttributeNames.type.ToString(),
                                                                                 type.ToString(), xDoc);

                foreach (var element in temp)
                {
                    tmpList.Add(element.Attribute(returnType.ToString()).Value);
                }
            }
            catch (Exception)
            {
                return(new List <string>());
            }

            return(tmpList);
        }
 internal ObjectDescriptor Skip(int start) => new ObjectDescriptor(Father, AttributeNames.Skip(start), AttributeValues.Skip(start).ToArray());
 internal ObjectDescriptor Split(int start, int take) => new ObjectDescriptor(Father, AttributeNames.Skip(start).Take(take), AttributeValues.Skip(start).Take(take).ToArray());
 internal ObjectDescriptor Take(int take) => new ObjectDescriptor(Father, AttributeNames.Take(take).ToArray(), AttributeValues.Take(take).ToArray());