public static void CastFromStringTest(string value, bool isError) { DataName instance = null; var errorOccured = false; try { instance = value; } catch (Exception ex) { logger.Exception(ex); errorOccured = true; } // エラーフラグが一致すること Assert.AreEqual(errorOccured, isError); if (errorOccured) { return; } // キャストした結果が一致すること Assert.AreEqual((string)instance, value); }
public string GeneratePrefix(string namespaceUri) { string prefix = DataName.GetStandardPrefix(namespaceUri); // TODO: establish more aesthetically pleasing prefixes return(prefix ?? String.Concat('q', ++nsCounter)); }
public static bool TryLoad(DataName dataName, out float dataOut) { string key = "F_" + dataName.ToString(); dataOut = PlayerPrefs.GetFloat(key); return(PlayerPrefs.HasKey(key)); }
private DataName EncodeName(DataName name, Type type) { // String.Empty is a valid DataName.LocalName, so must replace with type name if (String.IsNullOrEmpty(name.LocalName)) { foreach (DataName typeName in this.Settings.Resolver.LoadTypeName(type)) { if (typeName.IsEmpty) { continue; } return(typeName); } } // due to a bug in System.Xml.XmlCharType, // certain chars are not allowed that XML allows // so we must use XmlConvert to encode with same bug // XML only supports a subset of chars that DataName.LocalName does string localName = System.Xml.XmlConvert.EncodeLocalName(name.LocalName); if (name.LocalName == localName) { return(name); } return(new DataName(localName, name.Prefix, name.NamespaceUri, name.IsAttribute)); }
public ConventionBasedCodingStyle Merge(ConventionBasedCodingStyle other) { AddTypes(other.types); Type.Merge(other.Type); TypeIsValue.Merge(other.TypeIsValue); TypeIsView.Merge(other.TypeIsView); IdExtractor.Merge(other.IdExtractor); ValueExtractor.Merge(other.ValueExtractor); Locator.Merge(other.Locator); Converters.Merge(other.Converters); StaticInstances.Merge(other.StaticInstances); Initializers.Merge(other.Initializers); Datas.Merge(other.Datas); Operations.Merge(other.Operations); DataFetchedEagerly.Merge(other.DataFetchedEagerly); ParameterIsOptional.Merge(other.ParameterIsOptional); ParameterDefaultValue.Merge(other.ParameterDefaultValue); Module.Merge(other.Module); TypeName.Merge(other.TypeName); DataName.Merge(other.DataName); OperationName.Merge(other.OperationName); ParameterName.Merge(other.ParameterName); TypeMarks.Merge(other.TypeMarks); InitializerMarks.Merge(other.InitializerMarks); DataMarks.Merge(other.DataMarks); OperationMarks.Merge(other.OperationMarks); ParameterMarks.Merge(other.ParameterMarks); return(this); }
public T GetVariable <T>(int id, DataName dataName) where T : BaseVariable { if (!DataDictonary.ContainsKey(dataName)) { return(null); } Dictionary <DataName, BaseVariable> dictonary; if (!InstanceData.ContainsKey(id)) { dictonary = new Dictionary <DataName, BaseVariable>(); InstanceData.Add(id, dictonary); } else { dictonary = InstanceData[id]; } if (!dictonary.ContainsKey(dataName)) { dictonary.Add(dataName, ScriptableObject.Instantiate(DataDictonary[dataName].Variable)); } return((T)dictonary[dataName]); }
private DataName DecodeName(DataName name, Type type) { IEnumerable <DataName> defaultNames = this.Settings.Resolver.LoadTypeName(type); if (defaultNames != null) { foreach (DataName defaultName in defaultNames) { // String.Empty is a valid DataName.LocalName, so may have been replaced by type name if (name == defaultName) { return(DataName.Empty); } } } // due to a bug in System.Xml.XmlCharType, // certain chars are not allowed that XML allows // so we must use XmlConvert to encode with same bug // XML only supports a subset of chars that DataName.LocalName does string localName = System.Xml.XmlConvert.DecodeName(name.LocalName); if (name.LocalName == localName) { return(name); } return(new DataName(localName, name.Prefix, name.NamespaceUri, name.IsAttribute)); }
private void GetArrayTokens(List <Token <ModelTokenType> > tokens, ICycleDetector detector, IEnumerable value) { DataName typeName = this.GetTypeName(value); IEnumerator enumerator = value.GetEnumerator(); if (enumerator is IEnumerator <KeyValuePair <string, object> > ) { this.GetObjectTokens(tokens, detector, typeName, (IEnumerator <KeyValuePair <string, object> >)enumerator); return; } if (enumerator is IDictionaryEnumerator) { this.GetObjectTokens(tokens, detector, typeName, (IDictionaryEnumerator)enumerator); return; } tokens.Add(ModelGrammar.TokenArrayBegin(typeName)); while (enumerator.MoveNext()) { this.GetTokens(tokens, detector, enumerator.Current); } tokens.Add(ModelGrammar.TokenArrayEnd); }
/// <summary> /// Reads the data name and schema. /// </summary> /// <param name="dataRecord">The data record.</param> /// <returns></returns> protected virtual IDataName ReadDataNameAndSchema(IDataRecord dataRecord) { var dataName = new DataName { Name = dataRecord.GetAsString(0), Schema = dataRecord.GetAsString(1) }; return(dataName); }
public override int GetHashCode() { unchecked { return(((dataType != null ? dataType.GetHashCode() : 0) * 397) ^ (DataName != null ? DataName.GetHashCode() : 0)); } }
/// <summary> /// Gets all properties of the root object /// </summary> /// <param name="source"></param> /// <param name="predicate"></param> /// <returns>all properties for the object</returns> public static TokenSequence Property(this TokenSequence source, DataName propertyName) { using (var enumerator = ModelSubsequencer.Properties(source, name => (name == propertyName)).GetEnumerator()) { // effectively FirstOrDefault() return(enumerator.MoveNext() ? enumerator.Current.Value : null); } }
public override Int32 GetHashCode() { return(GameID.GetHashCode() ^ DataID.GetHashCode() ^ SaveTime.GetHashCode() ^ DataName.GetHashCode() ^ ScoreValue.GetHashCode()); }
protected override IDataName ReadDataNameAndSchema(IDataRecord dataRecord) { var dataName = new DataName { Name = dataRecord.GetAsString(0).TrimEnd(), Schema = dataRecord.GetAsString(1).TrimEnd() }; return(dataName); }
public void Receive() { while (true) { m_NetStream.Read(readBuffer, 0, readBuffer.Length); Packet packet = (Packet)Packet.Deserialize(this.readBuffer); switch ((int)packet.Type) { case (int)PacketType.이름과사이즈: { ListViewItem item; this.m_NameSize = (NameSize)Packet.Deserialize(this.readBuffer); this.Invoke(new MethodInvoker(delegate() { item = listView1.Items.Add(m_NameSize.name); item.SubItems.Add(m_NameSize.size.ToString()); })); break; } case (int)PacketType.일이름: { this.m_DataName = (DataName)Packet.Deserialize(this.readBuffer); break; } case (int)PacketType.일: { this.m_DataSend = (DataSend)Packet.Deserialize(this.readBuffer); FileStream fs = new FileStream(textBox3.Text + "\\" + m_DataName.name, FileMode.Append, FileAccess.Write); fs.Write(m_DataSend.data, 0, m_DataSend.data.Length); this.Invoke(new MethodInvoker(delegate() { progressBar1.Value += (int)(progressBar1.Maximum / ((progressBar1.Maximum / (1024 * 3)) + 1)); })); fs.Close(); if (m_DataSend.data.Length < 1024 * 3) { this.Invoke(new MethodInvoker(delegate() { progressBar1.Value = 0; })); } break; } } } }
public static void ToStringTest(string value) { var instance = new DataName(value); var strValue = instance.ToString(); // セットした値と取得した値が一致すること Assert.AreEqual(strValue, value); }
protected void OnUpdateNeedAttribute(List <AdditionalModel> needAttribute) { for (int i = 0; i < needAttribute.Count; i++) { string str = "需要" + DataName.Get_Name(needAttribute[i].Type, needAttribute[i].EnumType, true); float data = needAttribute[i].value; SetGame(NeedAttributeParent, str, data); } }
protected void OnUpdateAttribute(List <AdditionalModel> needAttribute, Transform parent) { for (int i = 0; i < needAttribute.Count; i++) { string str = DataName.Get_Name(needAttribute[i].Type, needAttribute[i].EnumType, true) + ":"; float data = needAttribute[i].value; SetGame(parent, str, data); } }
public override void OnUpdate() { base.OnUpdate(); if (!gameObject.activeSelf) { return; } SetName(_attribute.name, _attribute.GetEffect(Character.finalAttribute), _attribute.GetDescribe); if (_attribute.triggerType == 1) { SetGame(APParent, _attribute.GetAPText(Character.finalAttribute)); OnUpdateAttribute(_attribute.NeedAttribute, APParent); SetGame(NeedAttributeParent, _attribute.GetCDText(Character.finalAttribute)); if (_attribute.releaseRange > 1) { SetGame(NeedAttributeParent, "施法范围:", _attribute.releaseRange); } if (_attribute.targetRange > 1) { SetGame(NeedAttributeParent, "有效范围:", _attribute.targetRange); } if (_attribute.needEquipment.Length > 0) { string s = "需要"; switch (_attribute.needEquipment[0]) { case 1: s += (_attribute.needEquipment[1] == 1 ? "近战" : "远程") + "武器"; break; case 2: s += DataName.GetName(((EquipmentEnum)_attribute.needEquipment[1]).ToString(), true); break; case 3: s += DataName.GetName(((weaponEnum)_attribute.needEquipment[1]).ToString(), true); break; } SetGame(NeedAttributeParent, s); } } else { SetGame(AttributeParent, "被动技能"); } //技能是否已经学习,没有就需要显示学习条件 bool have = Character.dataModel.HaveSkill(Attribute); StudyNeedParent.gameObject.SetActive(!have); if (!have) { OnUpdateAttribute(_attribute.StudyNeedAttribute, StudyNeedParent); SetGame(StudyNeedParent, "等级:", _attribute.needLevel); } }
private void EmitTag(List <Token <MarkupTokenType> > output, DataName elementName, IDictionary <DataName, Token <ModelTokenType> > attributes, MarkupTokenType tagType) { if (this.pendingNewLine) { if (this.Settings.PrettyPrint) { this.depth++; this.EmitNewLine(output); } this.pendingNewLine = false; } PrefixScopeChain.Scope scope = new PrefixScopeChain.Scope(); scope.TagName = elementName; if (!this.ScopeChain.ContainsNamespace(elementName.NamespaceUri)) { scope[elementName.Prefix] = elementName.NamespaceUri; } this.ScopeChain.Push(scope); switch (tagType) { case MarkupTokenType.ElementVoid: { output.Add(MarkupGrammar.TokenElementVoid(elementName)); break; } case MarkupTokenType.ElementEnd: { output.Add(MarkupGrammar.TokenElementEnd); break; } default: case MarkupTokenType.ElementBegin: { output.Add(MarkupGrammar.TokenElementBegin(elementName)); break; } } if (attributes != null) { foreach (var attr in attributes) { output.Add(MarkupGrammar.TokenAttribute(attr.Key)); output.Add(attr.Value.ChangeType(MarkupTokenType.Primitive)); } attributes.Clear(); } }
/// <summary> /// Ctor /// </summary> /// <param name="map">MemberMap to clone</param> /// <param name="dataName">alternate name</param> public MemberMap(MemberMap map, DataName dataName) { this.MemberInfo = map.MemberInfo; this.Type = map.Type; this.Getter = map.Getter; this.Setter = map.Setter; this.IsIgnored = map.IsIgnored; this.DataName = dataName; this.IsAlternate = true; }
public string GetCDText(BaseAttribute character) { string s = "CD:"; if (character != null) { s += GetCD(character).ToString(); } if (CD.Length > 1) { s += string.Format("({0}-{1},得益于{2})", CD[0], CD[1], DataName.GetSkillName(CD[2], true)); } return(s); }
public string GetAPText(BaseAttribute character) { string s = "AP:"; if (character != null) { s += GetAP(character).ToString(); } if (AP.Length > 1) { s += string.Format("({0}-{1},得益于{2})", AP[0], AP[1], DataName.GetSkillName(AP[2], true)); } return(s); }
/// <summary> /// Ctor /// </summary> /// <param name="propertyInfo"></param> /// <param name="dataName"></param> /// <param name="isIgnored"></param> public MemberMap(PropertyInfo propertyInfo, DataName dataName, ValueIgnoredDelegate isIgnored) { if (propertyInfo == null) { throw new ArgumentNullException("propertyInfo"); } this.DataName = dataName; this.MemberInfo = propertyInfo; this.Name = propertyInfo.Name; this.Type = propertyInfo.PropertyType; this.Getter = DynamicMethodGenerator.GetPropertyGetter(propertyInfo); this.Setter = DynamicMethodGenerator.GetPropertySetter(propertyInfo); this.IsIgnored = isIgnored; }
/// <summary> /// Ctor /// </summary> /// <param name="fieldInfo"></param> /// <param name="dataName"></param> /// <param name="isIgnored"></param> public MemberMap(FieldInfo fieldInfo, DataName dataName, ValueIgnoredDelegate isIgnored) { if (fieldInfo == null) { throw new ArgumentNullException("fieldInfo"); } this.DataName = dataName; this.MemberInfo = fieldInfo; this.Name = fieldInfo.Name; this.Type = fieldInfo.FieldType; this.Getter = DynamicMethodGenerator.GetFieldGetter(fieldInfo); this.Setter = DynamicMethodGenerator.GetFieldSetter(fieldInfo); this.IsIgnored = isIgnored; }
/// <summary> /// Checks if the matching begin tag exists on the stack /// </summary> /// <returns></returns> public bool ContainsTag(DataName closeTag) { #if SILVERLIGHT foreach (var item in this.Chain) { if (item.TagName == closeTag) { return(true); } } return(false); #else // internal find is more efficient int index = this.Chain.FindLastIndex(item => item.TagName == closeTag); return(index >= 0); #endif }
public static void ConstructorTestB(DataName dataName, DBItemValueList itemValueList, bool isError) { var errorOccured = false; try { var _ = new DatabaseDataDesc(dataName, itemValueList); } catch (Exception ex) { logger.Exception(ex); errorOccured = true; } // エラーフラグが一致すること Assert.AreEqual(errorOccured, isError); }
public static void ConstructorTest(string value, bool isError) { var errorOccured = false; try { var _ = new DataName(value); } catch (Exception ex) { logger.Exception(ex); errorOccured = true; } // エラーフラグが一致すること Assert.AreEqual(errorOccured, isError); }
public JobName getJobName(DataName _dataName) { if (_dataName == DataName.SAPMO) { return(JobName.MO); } else if (_dataName == DataName.SAPMOBom) { return(JobName.MOBom); } else if (_dataName == DataName.SAPBom) { return(JobName.BOM); } return(JobName.MO); }
public static void Save <T>(DataName dataName, T data) { string key = typeof(T) + "_" + dataName.ToString(); if (SavedData.TryGetValue(key, out object thisData)) { SavedData[key] = data; } else { SavedData.Add(key, data); } string JsonString = JsonConvert.SerializeObject(data); PlayerPrefs.SetString(key, JsonString); }
public object[] GetSAPData(DataName _dataName, int inclusive, int exclusive) { if (_dataName == DataName.SAPMO) { //工单 return(this.GetSAPMO(inclusive, exclusive)); } else if (_dataName == DataName.SAPMOBom) { //工单BOM return(this.GetSAPMOBom(inclusive, exclusive)); } else if (_dataName == DataName.SAPBom) { //BOM return(this.GetSAPBOM(inclusive, exclusive)); } return(new object[] {}); }
public static Token<MarkupTokenType> TokenAttribute(DataName name) { return new Token<MarkupTokenType>(MarkupTokenType.Attribute, name); }
public static Token<MarkupTokenType> TokenElementVoid(DataName name) { return new Token<MarkupTokenType>(MarkupTokenType.ElementVoid, name); }
/// <summary> /// Marks the beginning of an object property /// </summary> /// <param name="name">the name of the property</param> /// <returns>PropertyKey Token</returns> public static Token<ModelTokenType> TokenProperty(DataName name) { return new Token<ModelTokenType>(ModelTokenType.Property, name); }
/// <summary> /// Marks the beginning of an object /// </summary> /// <param name="name">the name of the object</param> /// <returns>ObjectBegin Token</returns> public static Token<ModelTokenType> TokenObjectBegin(DataName name) { return new Token<ModelTokenType>(ModelTokenType.ObjectBegin, name); }
protected override IDataName ReadDataNameAndSchema(IDataRecord dataRecord) { var dataName = new DataName { Name = dataRecord.GetAsString(0).TrimEnd(), Schema = dataRecord.GetAsString(1).TrimEnd() }; return dataName; }
/// <summary> /// Marks the beginning of an array /// </summary> /// <param name="name">the name of the array</param> /// <returns>ArrayBegin Token</returns> public static Token<ModelTokenType> TokenArrayBegin(DataName name) { return new Token<ModelTokenType>(ModelTokenType.ArrayBegin, name); }
public Parameter(DataName name, bool isCustom, DataType type, int length=int.MaxValue) { this.Name = name; this.Type = type; this.Length = length; if (length < 1) throw new System.ArgumentOutOfRangeException("Length must be >0 (actual: "+length+')'); this.IsCustom = isCustom; }
public Parameter(DataName name) : this(name, false, null, int.MaxValue) { }
/// <summary> /// Reads the data name and schema. /// </summary> /// <param name="dataRecord">The data record.</param> /// <returns></returns> protected virtual IDataName ReadDataNameAndSchema(IDataRecord dataRecord) { var dataName = new DataName { Name = dataRecord.GetAsString(0), Schema = dataRecord.GetAsString(1) }; return dataName; }
/// <summary> /// Gets all properties of the root object /// </summary> /// <param name="source"></param> /// <param name="predicate"></param> /// <returns>all properties for the object</returns> public static TokenSequence Property(this TokenSequence source, DataName propertyName) { using (var enumerator = ModelSubsequencer.Properties(source, name => (name == propertyName)).GetEnumerator()) { // effectively FirstOrDefault() return enumerator.MoveNext() ? enumerator.Current.Value : null; } }
private static SyntacticQualifiedName qname(string uri, bool isFirstFilename = false) { var parts = uri.Split('.'); int p = 0; FileName filename = null; if (isFirstFilename) filename = new FileName(token(parts[p++])); var datanames = new List<DataName>(); while(p < parts.Length-1) datanames.Add(new DataName(token(parts[p++]))); var symbol = new DataName(token(parts[parts.Length-1])); return new SyntacticQualifiedName(symbol, datanames, filename); }