/// <summary> /// Sets an object's field with the specified value, /// coercing that value to the appropriate type if possible. /// </summary> /// <param name="target">Object containing the field to set.</param> /// <param name="fieldName">Name of the field (public or non-public) to set.</param> /// <param name="value">Value to set into the field.</param> public static void SetFieldValue( object target, string fieldName, object value) { DynamicMemberHandle handle = MethodCaller.GetCachedField(target.GetType(), fieldName); SetValueWithCoercion(target, handle, value); }
public static void Init () { // Fetch rect acessors using Reflection Assembly UnityEngine = Assembly.GetAssembly (typeof (UnityEngine.GUI)); Type GUIClipType = UnityEngine.GetType ("UnityEngine.GUIClip"); PropertyInfo topmostRect = GUIClipType.GetProperty ("topmostRect", BindingFlags.Static | BindingFlags.Public); MethodInfo GetTopRect = GUIClipType.GetMethod ("GetTopRect", BindingFlags.Static | BindingFlags.NonPublic); // Creating Fast.Reflection Delegates from those acessors // (First generic Parameter) -> Not actually GUI we're calling on but we cannot adress GUIClip as it's private and it's static so we would pass null anyways: GetTopRectDelegate = GetTopRect.DelegateForCall<GUI, Rect> (); topmostRectDelegate = topmostRect.DelegateForGet<GUI, Rect> (); // As we can call Begin/Ends inside another, we need to save their states hierarchial in Lists (not Stack, as we need to iterate over them!): currentRectStack = new List<Rect> (); rectStackGroups = new List<List<Rect>> (); GUIMatrices = new List<Matrix4x4> (); adjustedGUILayout = new List<bool> (); // Sometimes, strange errors pop up (related to Mac?), which we try to catch and enable a compability Mode no supporting zooming in groups try { topmostRectDelegate.Invoke (null); } catch { Debug.LogWarning ("GUIScaleUtility cannot run on this system! Compability mode enabled. For you that means you're not able to use the Node Editor inside more than one group:( Please PM me (Seneral @UnityForums) so I can figure out what causes this! Thanks!"); compabilityMode = true; } initiated = true; }
/// <summary> /// Copies values from the source into the /// properties of the target. /// </summary> /// <param name="source">An object containing the source values.</param> /// <param name="target">An object with properties to be set from the dictionary.</param> /// <param name="ignoreList">A list of property names to ignore. /// These properties will not be set on the target object.</param> /// <param name="suppressExceptions">If true, any exceptions will be supressed.</param> /// <remarks> /// <para> /// The property names and types of the source object must match the property names and types /// on the target object. Source properties may not be indexed. /// Target properties may not be readonly or indexed. /// </para><para> /// Properties to copy are determined based on the source object. Any properties /// on the source object marked with the <see cref="BrowsableAttribute"/> equal /// to false are ignored. /// </para> /// </remarks> public static void Map( object source, object target, bool suppressExceptions, params string[] ignoreList) { List <string> ignore = new List <string>(ignoreList); foreach (var propertyName in GetPropertyNames(source.GetType())) { if (!ignore.Contains(propertyName)) { try { object value = MethodCaller.CallPropertyGetter(source, propertyName); SetPropertyValue(target, propertyName, value); } catch (Exception ex) { if (!suppressExceptions) { throw new ArgumentException( String.Format("{0} ({1})", Resources.PropertyCopyFailed, propertyName), ex); } } } } }
/// <summary> /// Sets an object's property with the specified value, /// coercing that value to the appropriate type if possible. /// </summary> /// <param name="target">Object containing the property to set.</param> /// <param name="propertyName">Name of the property to set.</param> /// <param name="value">Value to set into the property.</param> public static void SetPropertyValue( object target, string propertyName, object value) { DynamicMemberHandle handle = MethodCaller.GetCachedProperty(target.GetType(), propertyName); SetValueWithCoercion(target, handle, value); }
public static void SafeInvoke <TTarget, TValue>(this MethodCaller <TTarget, TValue> caller, TTarget target, params object[] args) { if (caller != null) { caller(target, args); } }
/// <summary> /// Rule implementation. /// </summary> /// <param name="context">Rule context.</param> protected override void Execute(AuthorizationContext context) { var statusID = (int)MethodCaller.CallPropertyGetter(context.Target, _statusProperty); foreach (var status in _restrictedStatus) { if (status == statusID) { if (_roles.Count > 0) { if (_roles.Any(item => ApplicationContext.User.IsInRole(item))) { context.HasPermission = true; } } else { // if no role specified, allow all roles context.HasPermission = true; } } else { context.HasPermission = true; } } }
private void AsyncShowDetail(IAsyncResult result) { MethodCaller aysnDelegate = result.AsyncState as MethodCaller; if (aysnDelegate != null) { bool success = aysnDelegate.EndInvoke(result); if (success) { ConnDB conn = new ConnDB(); string strsql; DateTime begin_date, end_date; begin_date = Common.FirstDayOfMonth(dateTimePickerMonth.Value); end_date = Common.LastDayOfMonth(dateTimePickerMonth.Value); strsql = "select MATL_NO 料号,MATL_NAME 物料名称,PRICE 单价,BEGIN_DATE 价格开始日期,END_DATE 价格结束日期 from COST_MATL_PRICE where not (begin_date > '" + end_date + "' or end_date <'" + begin_date + "')"; DataSet ds = conn.ReturnDataSet(strsql); Action <DataSet> action = (data) => { gridControl1.DataSource = data.Tables[0].DefaultView; gridView1.Columns[0].Visible = false; gridView1.Columns[0].OptionsColumn.ReadOnly = true; gridView1.Columns[1].OptionsColumn.ReadOnly = true; gridView1.Columns[2].OptionsColumn.ReadOnly = true; gridView1.Columns[3].OptionsColumn.ReadOnly = true; gridView1.Columns[4].OptionsColumn.ReadOnly = true; simpleButton导入.Enabled = true; simpleButton清空.Enabled = true; }; Invoke(action, ds); conn.Close(); } } }
private void simpleButton导入_Click(object sender, EventArgs e) { simpleButton导入.Enabled = false; simpleButton清空.Enabled = false; ConnDB conn = new ConnDB(); string file = textEditFile.Text.ToString().Trim(); string sheet = comboBoxSheet.Text.ToString(); //string sql = "select * from COST_HH_STANDARD_HOURS where cmonth = '" + dateTimePickerMonth.Text + "'"; //int rows = conn.ReturnRecordCount(sql); //if (rows > 0) //{ // MessageBox.Show("该月标工已经存在,要重新导入,请先清空该月数据!"); // simpleButton导入.Enabled = true; // simpleButton清空.Enabled = true; //} //else if (file == "") { MessageBox.Show("没有选择文件", "提示信息", MessageBoxButtons.OK); simpleButton导入.Enabled = true; simpleButton清空.Enabled = true; } else if (sheet == "") { MessageBox.Show("请选择EXCEL表", "提示信息", MessageBoxButtons.OK); simpleButton导入.Enabled = true; simpleButton清空.Enabled = true; } else { MethodCaller mc = new MethodCaller(Import); IAsyncResult result = mc.BeginInvoke(file, sheet, AsyncShowDetail, mc); } }
/// <summary> /// Gets an object's field value. /// </summary> /// <param name="target">Object whose field value to get.</param> /// <param name="fieldName">The name of the field.</param> /// <returns>The value of the field.</returns> public static object GetFieldValue( object target, string fieldName) { DynamicMemberHandle handle = MethodCaller.GetCachedField(target.GetType(), fieldName); return(handle.DynamicMemberGet.Invoke(target)); }
/// <summary> /// Gets the real source helper method. /// </summary> /// <param name="source">The source.</param> /// <param name="bindingPath">The binding path.</param> /// <returns></returns> protected object GetRealSource(object source, string bindingPath) { var firstProperty = string.Empty; if (bindingPath.IndexOf('.') > 0) { firstProperty = bindingPath.Substring(0, bindingPath.IndexOf('.')); } var icv = source as ICollectionView; if (icv != null && firstProperty != "CurrentItem") { source = icv.CurrentItem; } if (source != null && !string.IsNullOrEmpty(firstProperty)) { var p = MethodCaller.GetProperty(source.GetType(), firstProperty); return(GetRealSource( MethodCaller.GetPropertyValue(source, p), bindingPath.Substring(bindingPath.IndexOf('.') + 1))); } else { return(source); } }
public static DataPortalMethodInfo GetMethodInfo(Type objectType, string methodName, params object[] parameters) { var key = new MethodCacheKey(objectType.FullName, methodName, MethodCaller.GetParameterTypes(parameters)); DataPortalMethodInfo result = null; var found = false; try { found = _cache.TryGetValue(key, out result); } catch { /* failure will drop into !found block */ } if (!found) { lock (_cache) { if (!_cache.TryGetValue(key, out result)) { result = new DataPortalMethodInfo(MethodCaller.GetMethod(objectType, methodName, parameters)); _cache.Add(key, result); } } } return(result); }
private void HandleTarget() { if (Target != null && !string.IsNullOrEmpty(Property)) { var b = Source as YYT.Security.IAuthorizeReadWrite; if (b != null) { bool canRead = b.CanReadProperty(Property); bool canWrite = b.CanWriteProperty(Property); if (canWrite) { MethodCaller.CallMethodIfImplemented(Target, "set_IsReadOnly", false); MethodCaller.CallMethodIfImplemented(Target, "set_IsEnabled", true); } else { MethodCaller.CallMethodIfImplemented(Target, "set_IsReadOnly", true); MethodCaller.CallMethodIfImplemented(Target, "set_IsEnabled", false); } if (!canRead) { MethodCaller.CallMethodIfImplemented(Target, "set_Content", null); MethodCaller.CallMethodIfImplemented(Target, "set_Text", ""); } } } }
/// <summary> /// Creates a serialization formatter object. /// </summary> public static ISerializationFormatter GetFormatter() { #if !NET5_0 if (ApplicationContext.SerializationFormatter == ApplicationContext.SerializationFormatters.BinaryFormatter) { return(new BinaryFormatterWrapper()); } #if !NETSTANDARD2_0 else if (ApplicationContext.SerializationFormatter == ApplicationContext.SerializationFormatters.NetDataContractSerializer) { return(new NetDataContractSerializerWrapper()); } #endif else #endif if (ApplicationContext.SerializationFormatter == ApplicationContext.SerializationFormatters.CustomFormatter) { string customFormatterTypeName = ConfigurationManager.AppSettings["CslaSerializationFormatter"]; return((ISerializationFormatter)MethodCaller.CreateInstance(Type.GetType(customFormatterTypeName, true, true))); } else { return(new Csla.Serialization.Mobile.MobileFormatter()); } }
private static EntityList QueryEntityListCore(HttpRequest request, EntityRepository repo, PagingInfo pagingInfo) { /*********************** 代码块解释 ********************************* * * 支持三种方法来查询数据库: * * 直接使用 Id 来查询 * * 指定方法名来查询 * * 指定查询条件进行查询。 * **********************************************************************/ EntityList entities = null; var filter = request.GetQueryStringOrDefault("filter", string.Empty); if (!string.IsNullOrEmpty(filter)) { var filters = JArray.Parse(filter); //GetByParentId(客户端所有的查询都应该通过 GetByCriteria,只有一个过滤条件时,必然是 GetByParentId) if (filters.Count == 1) { var parentId = ParseParentId(filters); //查询数据库 entities = repo.GetByParentId(parentId, pagingInfo); } else { var type = filters[0] as JObject; var useType = type.Property("property").Value.ToString(); switch (useType) { case "_useMethod": //使用 指定的方法 查询数据库 var method = type.Property("value").Value.ToString(); var parameters = ParseParameters(filters); entities = QueryByMethod(repo, method, parameters, pagingInfo); break; case "_useCriteria": //使用 Criteria 查询数据库 var criteria = ParseCriteria(filters, pagingInfo); entities = MethodCaller.CallMethod(repo, EntityConvention.GetByCriteriaMethod, criteria) as EntityList; break; default: break; } } } else { entities = repo.GetAll(pagingInfo); } return(entities); }
public void Initialize(MethodInfo method, object rawTarget, UnityObject unityTarget, int id, BaseGUI gui) { this.gui = gui; this.rawTarget = rawTarget; this.id = id; if (initialized) { return; } initialized = true; var commentAttr = method.GetCustomAttribute <CommentAttribute>(); if (commentAttr != null) { comment = commentAttr.comment; } niceName = method.GetNiceName(); if (niceName.IsPrefix("dbg") || niceName.IsPrefix("Dbg")) { niceName = niceName.Remove(0, 3); } invoke = method.DelegateForCall(); var argInfos = method.GetParameters(); int len = argInfos.Length; argValues = new object[len]; argKeys = new int[len]; argMembers = new EditorMember[len]; for (int iLoop = 0; iLoop < len; iLoop++) { int i = iLoop; var argInfo = argInfos[i]; argKeys[i] = RuntimeHelper.CombineHashCodes(id, argInfo.ParameterType.Name + argInfo.Name); argValues[i] = TryLoad(argInfos[i].ParameterType, argKeys[i]); argMembers[i] = EditorMember.WrapGetSet( @get: () => argValues[i], @set: x => argValues[i] = x, @rawTarget: rawTarget, @unityTarget: unityTarget, @attributes: argInfo.GetCustomAttributes(true) as Attribute[], @name: argInfo.Name, @id: argKeys[i], @dataType: argInfo.ParameterType ); } #if DBG Log("Method drawer init"); #endif }
protected override async Task OnStart() { _caller = await CreateMethodCaller <Integer, Integer>(":testmethod"); _sub = await SubscribeEvent <String>(":stringsforfun"); _sub.OnReceived += _sub_OnReceived; }
private OrderInfo GetOrderInfo(int id, string customerName) { var obj = (OrderInfo)MethodCaller.CreateInstance(typeof(OrderInfo)); LoadProperty(obj, OrderInfo.IdProperty, id); LoadProperty(obj, OrderInfo.CustomerNameProperty, customerName); return(obj); }
private void Form1_Load(object sender, EventArgs e) { MethodCaller mc = new MethodCaller(Read); IAsyncResult result = mc.BeginInvoke(@"C:\Users\lflx1\source\repos\ftpSwitch\dbs\psw.txt", null, null); PswList = mc.EndInvoke(result); ShowMsg("密码字典读取完成,最终行为:" + makePsw(PswList[PswList.Count - 1])); }
private YYT.Server.DataPortalResult CreateDesignTimeObject(Type objectType, object criteria, YYT.Server.DataPortalContext context) { var obj = Activator.CreateInstance(objectType, true); object returnValue = null; returnValue = MethodCaller.CallMethodIfImplemented(obj, "DesignTime_Create"); return(new YYT.Server.DataPortalResult(returnValue)); }
public void UtilsTest_Reflection_MethodCaller_ArgumentMatch3() { var res = (int)MethodCaller.CallMethod(this, "TestArguments", 1, new MethodCaller.NullParameter { ParameterType = typeof(string) }); Assert.IsTrue(res == 2); }
private void simpleButtonImport_Click(object sender, EventArgs e) { //Import(); simpleButtonImport.Enabled = false; simpleButtonClear.Enabled = false; MethodCaller mc = new MethodCaller(Import); IAsyncResult result = mc.BeginInvoke(AsyncShowDetail, mc); }
public object CreateInstance(Type requestedType) { if (requestedType == null) { throw new ArgumentNullException(nameof(requestedType)); } return(MethodCaller.CreateInstance(requestedType)); }
/// <inheritdoc/> public override void Dispose() { #if !NET_STANDARD_2_0 && USE_IL_FOR_GET_AND_SET getMethod = null; setMethod = null; #endif LinkedMemberInfoPool.Dispose(this); }
public Order Create() { var obj = (Order)MethodCaller.CreateInstance(typeof(Order)); LoadProperty(obj, Order.IdProperty, -1); MarkNew(obj); CheckRules(obj); return(obj); }
public void CallByConvention(object parameter) { MethodCollector collector = new MethodCollector(_target); MethodInfo firstMethodMatch = collector.CollectFirstMatch(new MethodQueryCriteria(parameter)); MethodCaller caller = new MethodCaller(firstMethodMatch); caller.Call(_target, parameter); }
private Delegate CreateHandler(Type objectType) { System.Reflection.MethodInfo method = MethodCaller.GetNonPublicMethod(GetType(), "QueryCompleted"); var innerType = typeof(DataPortalResult <>).MakeGenericType(objectType); var args = typeof(EventHandler <>).MakeGenericType(innerType); Delegate handler = Delegate.CreateDelegate(args, this, method); return(handler); }
public void UtilsTest_Reflection_MethodCaller_ArgumentMatch2() { try { var res = (int)MethodCaller.CallMethod(this, "TestArguments", 1, null); Assert.IsFalse(true, "应该找到过多的方法。"); } catch (InvalidProgramException) { } }
public async Task CallMethodWithoutParams() { var srv = new TestService(); var parameters = JObject.FromObject(new { }); var result = await MethodCaller.Call(typeof(ITestService), srv, "MethodWithoutParams", parameters); Assert.False(result.IsVoid); Assert.Equal(TestService.NoParamsResult, result.Result); }
public void UtilsTest_Reflection_MethodCaller_ArgumentMatch1() { try { MethodCaller.CallMethod(this, "TestArguments", null, ""); Assert.IsFalse(true, "应该无法找到对应的方法。"); } catch (InvalidProgramException) { } }
public async Task CallVoidMethodWithoutParams() { var srv = new TestService(); var parameters = JObject.FromObject(new {}); var result = await MethodCaller.Call(typeof(ITestService), srv, "VoidMethodWithoutParams", parameters); Assert.True(result.IsVoid); Assert.Null(result.Result); }
public void Execute(string factoryMethod, params object[] factoryParameters) { var parameters = new List <object>(factoryParameters) { CreateHandler() }; MethodCaller.CallFactoryMethod(typeof(T), factoryMethod, parameters.ToArray()); }
private void button3_Click(object sender, EventArgs e) { if (IsCountDone == true) { IsCountDone = false; Thread 白平衡執行序 = new Thread(new ThreadStart(delegate { MethodCaller mc = new MethodCaller(AutoWhiteBalance); if (pictureBox3.Image != null) { Bitmap bm = new Bitmap(pictureBox3.Image); IAsyncResult result = mc.BeginInvoke(bm, null, null); Bitmap bm1 = mc.EndInvoke(result);//用於接收返回值 pictureBox3.Image = bm1; } else if (pictureBox1.Image != null) { Bitmap bm = new Bitmap(pictureBox1.Image); IAsyncResult result = mc.BeginInvoke(bm, null, null); Bitmap bm1 = mc.EndInvoke(result);//用於接收返回值 pictureBox3.Image = bm1; //AutoWhiteBalance(bm); //pictureBox3.Image = bm; } else { MessageBox.Show("尚未選擇來源圖檔"); } })); 白平衡執行序.Start(); } else { MessageBox.Show("圖片運算尚未完成,請稍後"); } //Bitmap bm = new Bitmap(pictureBox1.Image); //IAsyncResult result = mc.BeginInvoke(bm, null, null); //Bitmap bm1 = mc.EndInvoke(result);//用於接收返回值 //pictureBox3.Image = bm1; //if(pictureBox3.Image != null) //{ // pictureBox3.Image.Dispose(); //} //if(pictureBox1.Image != null) //{ // Bitmap bitmap; // bitmap = new Bitmap(pictureBox1.Image); // //ContrastP(bitmap, 圖像對比數值); // pictureBox3.Image = bitmap; //} //else //{ // MessageBox.Show("尚未選擇來源圖檔"); //} }
public void Initialize(MethodInfo method, object rawTarget, UnityObject unityTarget, int id, BaseGUI gui, EditorRecord prefs) { this.prefs = prefs; this.gui = gui; this.rawTarget = rawTarget; this.unityTarget = unityTarget; this.id = id; if (initialized) return; initialized = true; isCoroutine = method.ReturnType == typeof(IEnumerator); var commentAttr = method.GetCustomAttribute<CommentAttribute>(); if (commentAttr != null) comment = commentAttr.comment; niceName = method.GetNiceName(); if (niceName.IsPrefix("dbg") || niceName.IsPrefix("Dbg")) niceName = niceName.Remove(0, 3); invoke = method.DelegateForCall(); var argInfos = method.GetParameters(); int len = argInfos.Length; argValues = new object[len]; argKeys = new int[len]; argMembers = new EditorMember[len]; for (int iLoop = 0; iLoop < len; iLoop++) { int i = iLoop; var argInfo = argInfos[i]; argKeys[i] = RuntimeHelper.CombineHashCodes(id, argInfo.ParameterType.Name + argInfo.Name); argValues[i] = TryLoad(argInfos[i].ParameterType, argKeys[i]); argMembers[i] = EditorMember.WrapGetSet( @get : () => argValues[i], @set : x => argValues[i] = x, @rawTarget : rawTarget, @unityTarget : unityTarget, @attributes : argInfo.GetCustomAttributes(true) as Attribute[], @name : argInfo.Name, @id : argKeys[i], @dataType : argInfo.ParameterType ); } #if DBG Log("Method drawer init"); #endif }
// private static Type GUILayoutGroupType; // private static Type GUILayoutEntryType; // // private static FieldInfo LayoutGroupRect; // private static FieldInfo LayoutEntryHeight; // private static FieldInfo LayoutEntryWidth; // private static PropertyInfo LayoutEntryStyle; public static void Init() { Assembly UnityEngine = Assembly.GetAssembly (typeof (UnityEngine.GUI)); Type GUIClipType = UnityEngine.GetType ("UnityEngine.GUIClip"); PropertyInfo topmostRect = GUIClipType.GetProperty ("topmostRect", BindingFlags.Static | BindingFlags.Public); MethodInfo GetTopRect = GUIClipType.GetMethod ("GetTopRect", BindingFlags.Static | BindingFlags.NonPublic); // Not actually GUI we're calling on but we cannot adress GUIClip as it's private and it's static so we would pass null anyways: GetTopRectDelegate = GetTopRect.DelegateForCall<GUI, Rect> (); topmostRectDelegate = topmostRect.DelegateForGet<GUI, Rect> (); // As we can call Begin/Ends inside another, we need to save their states hierarchial in Lists: currentRectStack = new List<Rect> (); rectStackGroups = new List<List<Rect>> (); GUIMatrices = new List<Matrix4x4> (); adjustedGUILayout = new List<bool> (); try { topmostRectDelegate.Invoke (null); } catch { Debug.LogWarning ("GUIScaleUtility cannot run on this system! Compability mode enabled. For you that means you're not able to use the Node Editor inside more than one group:( Please PM me (Seneral @UnityForums) so I can figure out what causes this! Thanks!"); compabilityMode = true; } // Type GUILayoutUtilityType = UnityEngine.GetType ("UnityEngine.GUILayoutUtility"); // currentGUILayoutCache = GUILayoutUtilityType.GetField ("current", BindingFlags.Static | BindingFlags.NonPublic); // // Type GUILayoutCacheType = GUILayoutUtilityType.GetNestedType ("LayoutCache", BindingFlags.NonPublic); // currentTopLevelGroup = GUILayoutCacheType.GetField ("topLevel", BindingFlags.NonPublic | BindingFlags.Instance); // // GUILayoutGroupType = UnityEngine.GetType ("UnityEngine.GUILayoutGroup"); // GUILayoutEntryType = UnityEngine.GetType ("UnityEngine.GUILayoutEntry"); // // LayoutGroupRect = GUILayoutGroupType.GetField ("rect"); // // LayoutEntryHeight = GUILayoutEntryType.GetField ("maxHeight"); // LayoutEntryWidth = GUILayoutEntryType.GetField ("maxWidth"); // LayoutEntryStyle = GUILayoutEntryType.GetProperty ("style"); }
public void MSOXCMAPIHTTP_S01_TC07_SimultaneousRequestWithinSameSessionContext() { this.CheckMapiHttpIsSupported(); MailboxResponseBodyBase responseBody; #region Send a valid Connect request type to establish a Session Context with the server. WebHeaderCollection connectHeaders = new WebHeaderCollection(); ConnectSuccessResponseBody connectResponse = this.ConnectToServer(out connectHeaders); #endregion #region Send two Execute request that includes Logon ROP to server simultaneously uint firstResponseCode; uint secondResponseCode; CookieCollection firstCookies = new CookieCollection(); CookieCollection secondCookies = new CookieCollection(); foreach (Cookie cookie in AdapterHelper.SessionContextCookies) { Cookie c = new Cookie(cookie.Name, cookie.Value, cookie.Path, cookie.Domain); firstCookies.Add(c); secondCookies.Add(c); } MethodCaller asyncThread = new MethodCaller( () => { return this.ExecuteLogonROP(firstCookies); }); IAsyncResult result = asyncThread.BeginInvoke(null, null); secondResponseCode = this.ExecuteLogonROP(secondCookies); firstResponseCode = asyncThread.EndInvoke(result); // Add the debug information this.Site.Log.Add( LogEntryKind.Debug, "Verify MS-OXCMAPIHTTP_R1228: When the client has issued simultaneous requests within a Session Context,the first X-Response header is {0} and the second X-Response header is {1}.", firstResponseCode, secondResponseCode); // Verify MS-OXCMAPIHTTP requirement: MS-OXCMAPIHTTP_R1228 bool isVerifiedR1228 = firstResponseCode == 15 || secondResponseCode == 15; this.Site.CaptureRequirementIfIsTrue( isVerifiedR1228, 1228, @"[In Responding to a Connect or Bind Request Type Request] If the server detects that the client has issued simultaneous requests within a Session Context, the server MUST fail every subsequent request with a value of 15 (""Invalid Sequence"" error) in the X-ResponseCode header."); // If the R1228 has been verified, then server return the X-ResponseCode 15 when the request has violated the sequencing requirement of one request at a time per Session Context. // So R151 will be verified. this.Site.CaptureRequirement( 151, @"[In X-ResponseCode Header Field] Invalid Sequence (15): The request has violated the sequencing requirement of one request at a time per Session Context."); #endregion #region Send a Disconnect request type request to destroy the Session Context. this.Adapter.Disconnect(out responseBody); #endregion }
public BaseDrawer Initialize(EditorMember member, Attribute[] attributes, BaseGUI gui) { if (attributes == null) attributes = Empty; this.member = member; this.attributes = attributes; this.gui = gui; if (_dynamicFormatter != null) { _formatArgs[0] = member.Value; displayText = _dynamicFormatter(rawTarget, _formatArgs); } if (_hasInit) { #if DBG Log(this + " is Already initialized"); #endif return this; } #if DBG Log("Initializing: " + this); #endif var displayAttr = attributes.GetAttribute<DisplayAttribute>(); if (displayAttr != null && MemberDrawersHandler.IsApplicableAttribute(memberType, displayAttr, attributes)) { var hasCustomFormat = !string.IsNullOrEmpty(displayAttr.FormatMethod); var formatMethod = hasCustomFormat ? displayAttr.FormatMethod : ("Format" + member.Name); var method = targetType.GetMemberFromAll(formatMethod, Flags.StaticInstanceAnyVisibility) as MethodInfo; if (method == null) { if (hasCustomFormat) Debug.Log("Couldn't find format method: " + displayAttr.FormatMethod); } else { if (method.ReturnType != typeof(string) && method.GetParameters().Length > 0) Debug.Log("Format Method should return a string and take no parameters: " + method); else { _dynamicFormatter = method.DelegateForCall<object, string>(); _formatArgs[0] = member.Value; displayText = _dynamicFormatter(rawTarget, _formatArgs); } } } _hasInit = true; InternalInitialize(); Initialize(); return this; }