public XbimPropertyDescriptor(string propertyName, GetValueCallback <T, P> getValueCallback, SetValueCallback <T, P> setValueCallback) : base(propertyName, null) { _getValueCallback = getValueCallback; _setValueCallback = setValueCallback; }
/// <summary> Get values at time </summary> public virtual void GetValues(GetValueCallback callback, float time) { KeyValuePair <string, float>[] pairs = GetValues(time); for (int i = 0; i < pairs.Length; i++) { callback.Invoke(pairs[i].Key, pairs[i].Value); } }
public int GetValue() { if (this.InvokeRequired) { GetValueCallback d = new GetValueCallback(GetValue); return((int)this.Invoke(d, new object[] { })); } else { return(this.Value); } }
protected static string SubstituteKownValue(string transformValue, RegularExpressions.Regex patternRegex, string patternPrefix, GetValueCallback getValueDelegate ) { int position = 0; List<RegularExpressions.Match> matchsExpr = new List<RegularExpressions.Match>(); do { position = transformValue.IndexOf(patternPrefix, position, StringComparison.OrdinalIgnoreCase); if (position > -1) { RegularExpressions.Match match = patternRegex.Match(transformValue, position); // Add the successful match to collection if (match.Success) { matchsExpr.Add(match); position = match.Index + match.Length; } else { position++; } } } while (position > -1); System.Text.StringBuilder strbuilder = new StringBuilder(transformValue.Length); if (matchsExpr.Count > 0) { strbuilder.Remove(0, strbuilder.Length); position = 0; int index = 0; foreach (RegularExpressions.Match match in matchsExpr) { strbuilder.Append(transformValue.Substring(position, match.Index - position)); RegularExpressions.Capture captureTagName = match.Groups["tagname"]; string attributeName = captureTagName.Value; string newValue = getValueDelegate(attributeName); if (newValue != null) // null indicate that the attribute is not exist { strbuilder.Append(newValue); } else { // keep original value strbuilder.Append(match.Value); } position = match.Index + match.Length; index++; } strbuilder.Append(transformValue.Substring(position)); transformValue = strbuilder.ToString(); } return transformValue; }
private string TokenizeValue(XmlAttribute targetAttribute, XmlAttribute transformAttribute, bool fTokenizeParameter, List <Dictionary <string, string> > parameters) { this.tokenizeValueCurrentXmlAttribute = transformAttribute; string xPathToAttribute = this.GetXPathToAttribute(targetAttribute); string input = SubstituteKownValue(transformAttribute.Value, ParentAttributeRegex, "$(", key => this.EscapeDirRegexSpecialCharacter(this.GetAttributeValue(key), true)); if (fTokenizeParameter && (parameters != null)) { int startIndex = 0; StringBuilder builder = new StringBuilder(input.Length); startIndex = 0; List <Match> list = new List <Match>(); while (true) { startIndex = input.IndexOf("{%", startIndex, StringComparison.OrdinalIgnoreCase); if (startIndex > -1) { Match item = DirRegex.Match(input, startIndex); if (!item.Success) { startIndex++; } else { list.Add(item); startIndex = item.Index + item.Length; } } if (startIndex <= -1) { if (list.Count > 0) { builder.Remove(0, builder.Length); startIndex = 0; int num2 = 0; foreach (Match match2 in list) { builder.Append(input.Substring(startIndex, match2.Index - startIndex)); CaptureCollection captures = match2.Groups["attrname"].Captures; if ((captures != null) && (captures.Count > 0)) { GetValueCallback getValueDelegate = null; CaptureCollection captures2 = match2.Groups["attrval"].Captures; Dictionary <string, string> paramDictionary = new Dictionary <string, string>(4, StringComparer.OrdinalIgnoreCase) { [XPathWithIndex] = xPathToAttribute, [TokenNumber] = num2.ToString(CultureInfo.InvariantCulture) }; int num3 = 0; while (true) { if (num3 >= captures.Count) { string tokenFormat = null; if (!paramDictionary.TryGetValue(Token, out tokenFormat)) { tokenFormat = this.storageDictionary.TokenFormat; } if (!string.IsNullOrEmpty(tokenFormat)) { paramDictionary[Token] = tokenFormat; } int count = paramDictionary.Count; string[] array = new string[count]; paramDictionary.Keys.CopyTo(array, 0); int index = 0; while (true) { if (index >= count) { string str9; if (paramDictionary.TryGetValue(Token, out tokenFormat)) { builder.Append(tokenFormat); } if (paramDictionary.TryGetValue(XpathLocator, out str9) && !string.IsNullOrEmpty(str9)) { IList <string> locators = XmlArgumentUtility.SplitArguments(str9); string str10 = this.GetXPathToAttribute(targetAttribute, locators); if (!string.IsNullOrEmpty(str10)) { paramDictionary[XPathWithLocator] = str10; } } parameters.Add(paramDictionary); break; } string str6 = array[index]; string transformValue = paramDictionary[str6]; if (getValueDelegate == null) { getValueDelegate = key => paramDictionary.ContainsKey(key) ? paramDictionary[key] : null; } paramDictionary[str6] = SubstituteKownValue(transformValue, TokenFormatRegex, "#(", getValueDelegate); index++; } break; } string str3 = captures[num3].Value; string str4 = null; if ((captures2 != null) && (num3 < captures2.Count)) { str4 = this.EscapeDirRegexSpecialCharacter(captures2[num3].Value, false); } paramDictionary[str3] = str4; num3++; } } startIndex = match2.Index + match2.Length; num2++; } builder.Append(input.Substring(startIndex)); input = builder.ToString(); } break; } } } return(input); }
protected static string SubstituteKownValue(string transformValue, Regex patternRegex, string patternPrefix, GetValueCallback getValueDelegate) { int startIndex = 0; List <Match> list = new List <Match>(); while (true) { startIndex = transformValue.IndexOf(patternPrefix, startIndex, StringComparison.OrdinalIgnoreCase); if (startIndex > -1) { Match item = patternRegex.Match(transformValue, startIndex); if (!item.Success) { startIndex++; } else { list.Add(item); startIndex = item.Index + item.Length; } } if (startIndex <= -1) { StringBuilder builder = new StringBuilder(transformValue.Length); if (list.Count > 0) { builder.Remove(0, builder.Length); startIndex = 0; int num2 = 0; foreach (Match match2 in list) { builder.Append(transformValue.Substring(startIndex, match2.Index - startIndex)); Capture capture = match2.Groups["tagname"]; string key = capture.Value; string str2 = getValueDelegate(key); if (str2 != null) { builder.Append(str2); } else { builder.Append(match2.Value); } startIndex = match2.Index + match2.Length; num2++; } builder.Append(transformValue.Substring(startIndex)); transformValue = builder.ToString(); } return(transformValue); } } }
protected static string SubstituteKownValue(string transformValue, RegularExpressions.Regex patternRegex, string patternPrefix, GetValueCallback getValueDelegate) { int position = 0; List <RegularExpressions.Match> matchsExpr = new List <RegularExpressions.Match>(); do { position = transformValue.IndexOf(patternPrefix, position, StringComparison.OrdinalIgnoreCase); if (position > -1) { RegularExpressions.Match match = patternRegex.Match(transformValue, position); // Add the successful match to collection if (match.Success) { matchsExpr.Add(match); position = match.Index + match.Length; } else { position++; } } } while (position > -1); System.Text.StringBuilder strbuilder = new StringBuilder(transformValue.Length); if (matchsExpr.Count > 0) { strbuilder.Remove(0, strbuilder.Length); position = 0; int index = 0; foreach (RegularExpressions.Match match in matchsExpr) { strbuilder.Append(transformValue.Substring(position, match.Index - position)); RegularExpressions.Capture captureTagName = match.Groups["tagname"]; string attributeName = captureTagName.Value; string newValue = getValueDelegate(attributeName); if (newValue != null) // null indicate that the attribute is not exist { strbuilder.Append(newValue); } else { // keep original value strbuilder.Append(match.Value); } position = match.Index + match.Length; index++; } strbuilder.Append(transformValue.Substring(position)); transformValue = strbuilder.ToString(); } return(transformValue); }
public void SetCallbacks (GetValueCallback get_value, GetValueArrayCallback get_value_array) { IntPtr off = new IntPtr (Handle.ToInt64 () + get_value_offset); GstControlSourceCallbacks cbs = (GstControlSourceCallbacks) Marshal.PtrToStructure (new IntPtr (Handle.ToInt64 () + get_value_offset), typeof (GstControlSourceCallbacks)); GetValueCallbackWrapper gv_wr = new GetValueCallbackWrapper (get_value); GetValueArrayCallbackWrapper gva_wr = new GetValueArrayCallbackWrapper (get_value_array); GetValue_cb_wrapper = gv_wr; GetValueArray_cb_wrapper = gva_wr; cbs.get_value = gv_wr.NativeCallback; cbs.get_value_array = gva_wr.NativeCallback; Marshal.StructureToPtr (cbs, off, false); }
public GetValueCallbackWrapper (GetValueCallback managed) { this.managed = managed; if (managed != null) NativeDelegate = new GetValueCallbackNative (NativeCallback); }