private void CorrectOutMessageForOperationWithFault(Receive receive, OperationInfo operationInfo) { Receive receive2 = operationInfo.Receive; if (((receive != receive2) && receive.HasReply) && (!receive2.HasReply && receive2.HasFault)) { ContractInferenceHelper.CorrectOutMessageForOperation(receive, operationInfo.OperationDescription); operationInfo.Receive = receive; } }
public void Setup() { var method = typeof(TestController).GetMethod("Add"); _controller = new TestController(); _operation = new OperationInfo<Verb>( method, (HttpUrl)UrlParser.Parse("/add"), "/api/test/add?{?operandA}&{?operandB}", new Regex(".*"), Verb.GET, method.GetParameters().Select(parameter => (ValueInfo)new ArgumentInfo(parameter, FromQueryStringAttribute.For(parameter), "add?{?" + parameter.Name + "}", parameter.Name)).ToArray()); var controllerInfo = new ControllerInfo<TestController>(null, (HttpUrl)UrlParser.Parse("api/test"), _operation); Mock<IHttpControllerDescriptionBuilder> controllerDescriptionBuilder = new Mock<IHttpControllerDescriptionBuilder>(MockBehavior.Strict); controllerDescriptionBuilder.Setup(instance => instance.BuildDescriptor()).Returns(controllerInfo); Mock<IControllerActivator> controllerActivator = new Mock<IControllerActivator>(MockBehavior.Strict); controllerActivator.Setup(instance => instance.CreateInstance(It.IsAny<Type>(), It.IsAny<IDictionary<string, object>>())).Returns(_controller); _delegateMapper = new DelegateMapper(new[] { controllerDescriptionBuilder.Object }, controllerActivator.Object); }
private void CreatButton() { try { PanelBasicOpts.Children.Clear(); for (int i = 0; i < mListOperations.Count; i++) { OperationInfo item = mListOperations[i]; //基本操作按钮 Button btn = new Button(); btn.Click += OptBtn_Click; btn.DataContext = item; btn.SetResourceReference(StyleProperty, "OptButtonStyle"); PanelBasicOpts.Children.Add(btn); } } catch (Exception ex) { ShowException(ex.Message); } }
public void Setup() { var method = typeof(TestController).GetMethod("Add"); _controller = new TestController(); _operation = new OperationInfo <Verb>( method, (HttpUrl)UrlParser.Parse("/add"), "/api/test/add?{?operandA}&{?operandB}", new Regex(".*"), Verb.GET, method.GetParameters().Select(parameter => (ValueInfo) new ArgumentInfo(parameter, FromQueryStringAttribute.For(parameter), "add?{?" + parameter.Name + "}", parameter.Name)).ToArray()); var controllerInfo = new ControllerInfo <TestController>(null, (HttpUrl)UrlParser.Parse("api/test"), _operation); Mock <IHttpControllerDescriptionBuilder> controllerDescriptionBuilder = new Mock <IHttpControllerDescriptionBuilder>(MockBehavior.Strict); controllerDescriptionBuilder.Setup(instance => instance.BuildDescriptor()).Returns(controllerInfo); Mock <IControllerActivator> controllerActivator = new Mock <IControllerActivator>(MockBehavior.Strict); controllerActivator.Setup(instance => instance.CreateInstance(It.IsAny <Type>(), It.IsAny <IDictionary <string, object> >())).Returns(_controller); _delegateMapper = new DelegateMapper(new[] { controllerDescriptionBuilder.Object }, controllerActivator.Object); }
public void TestProperties() { var settings = new BinaryFileSystemOperationSettings( new string[] { }, new[] { SourceName }, new string[] { }, new[] { DestinationName }, new Dictionary <string, string> { [SourceName] = DestinationName }, new string[] { } ); var operationInfo = new OperationInfo(OperationType.Copy, settings); _autoMocker.Use(operationInfo); var operation = _autoMocker.CreateInstance <CompositeOperation>(); Assert.Equal(operationInfo, operation.Info); Assert.Equal(default, operation.CurrentBlockedFile);
public Operation(OperationInfo opInfo) { InitializeComponent(); info = opInfo; // Загружаем данные о личности в интерфейс. TB_Name.Text = info.patient.Person["name"]; TB_Surname.Text = info.patient.Person["surname"]; TB_Title.Text = info.patient.Person["title"]; TB_ID.Text = info.patient.id; LogMessage("Начало операции над " + TB_Name.Text + " " + TB_Surname.Text); // Загружаем данные о ранениях и характеристиках в интерфейс. GUIUpdateStats(); GUIUpdateDamages(); // Прячем индикатор крит. состояния и деактивируем таймер мерцания. LB_Critical.Visible = false; TMR_CritFlickering.Enabled = false; }
private void InitButton() { try { ButSearchContent.Children.Clear(); var btn = new Button(); btn.Click += SearchContents_Click; var opt = new OperationInfo { Icon = "Images/search.png" }; TbSearchContent.Text = CurrentApp.GetLanguageInfo("3604T00007", "Search Content"); btn.DataContext = opt; btn.SetResourceReference(StyleProperty, "OptButtonStyle"); ButSearchContent.Children.Add(btn); } catch (Exception ex) { ShowException(ex.Message); } }
internal static IOperation AsOperation <T>(this OperationInfo <T> operation, IApiDocumentation apiDocumentation, EntityId id = null) { var methodId = id ?? operation.CreateId(apiDocumentation.Context.BaseUriSelector.SelectBaseUri(new EntityId(new Uri("/", UriKind.Relative)))); if (operation.IsWriteControllerOperation()) { switch (operation.UnderlyingMethod.Name) { case "Delete": return(apiDocumentation.Context.Create <IDeleteResourceOperation>(methodId)); case "Update": return(apiDocumentation.Context.Create <IReplaceResourceOperation>(methodId)); case "Create": return(apiDocumentation.Context.Create <ICreateResourceOperation>(methodId)); } } return(apiDocumentation.Context.Create <IOperation>(methodId)); }
internal static string MakeUri(ParameterInfo parameter, HttpUrl baseUrl, OperationInfo <Verb> operation) { string result = baseUrl.ToString(); foreach (var argument in operation.Arguments) { var argumentSource = argument.Source; if (!(argumentSource is FromUrlAttribute)) { continue; } var url = ((FromUrlAttribute)argumentSource).UrlTemplate.Replace(FromUrlAttribute.Key, "/" + argument.Parameter.Name + "/").TrimStart('/'); result += (result.EndsWith("/") ? String.Empty : "/") + url; if (argument.Parameter == parameter) { break; } } return(result); }
public void Setup() { var method = typeof(TestController).GetMethod("Add"); var baseUri = (HttpUrl)UrlParser.Parse("/api/test/"); var operationUri = ((HttpUrl)UrlParser.Parse("/add")).InsertSegments(0, baseUri.Segments); var operation = new OperationInfo <Verb>( method, operationUri, operationUri + "?operandA={?operandA}&operandB={?operandB}", new Regex(operationUri.ToString(), RegexOptions.IgnoreCase), Verb.GET, new ArgumentInfo(method.GetParameters()[0], FromQueryStringAttribute.For(method.GetParameters()[0]), "&operandA={?operandA}", "operandA"), new ArgumentInfo(method.GetParameters()[1], FromQueryStringAttribute.For(method.GetParameters()[1]), "&operandB={?operandB}", "operandB")); var description = new ControllerInfo <TestController>(null, (HttpUrl)UrlParser.Parse("/api/test/"), operation); Mock <IHttpControllerDescriptionBuilder <TestController> > builder = new Mock <IHttpControllerDescriptionBuilder <TestController> >(); builder.As <IControllerDescriptionBuilder>().Setup(instance => instance.BuildDescriptor()).Returns(description); Mock <IControllerActivator> activator = new Mock <IControllerActivator>(); activator.Setup(instance => instance.CreateInstance(It.IsAny <Type>(), It.IsAny <IDictionary <string, object> >())).Returns(new TestController()); _mapper = new DelegateMapper(new IHttpControllerDescriptionBuilder[] { builder.Object }, activator.Object); }
// Context: client | async. // public void CancelAllAsync() { if (!_supportsCancellation) { throw new InvalidOperationException("This instance of the QueuedBackgroundWorker does not support cancellation."); } lock (_collectionsLock) { _cancelAllPending = true; foreach (object key in _userStateToOperationMap.Keys) { OperationInfo opInfo = _userStateToOperationMap[key] as OperationInfo; if (opInfo != null) { opInfo.OperationRequest.Cancel(); } } } }
private void OnRefreshOperationsClick(object sender, EventArgs e) { try { TaskNode tn = this.SelectedNode as TaskNode; if (tn != null) { tn.Nodes.Clear(); TaskInfo task = ConfigCtrl.GetTask(tn.Task.TaskId, tn.Task.TaskName, false); foreach (AccountInfo account in task.Accounts) { OperationInfo operation = ConfigCtrl.GetOperation(task.GroupName, account); OperationNode an = new OperationNode(operation); tn.Nodes.Add(an); } } } catch (Exception ex) { ErrorHandler.ShowMessageBox(TaskConstants.EXCEPTION_MODULE, ex); } }
internal bool CheckOperation(ulong guid) { bool ret = true; long curTime = TimeUtility.GetLocalMilliseconds(); OperationInfo opInfo; if (m_OperationInfos.TryGetValue(guid, out opInfo)) { if (opInfo.m_LastTime + c_MonitorInterval < curTime) { opInfo.m_Count = 0; opInfo.m_LastTime = curTime; } else { ++opInfo.m_Count; if (opInfo.m_Count > c_MaxOperationCount) { ret = false; } } } else { opInfo = new OperationInfo(); opInfo.m_LastTime = curTime; m_OperationInfos.TryAdd(guid, opInfo); } return ret; }
public OptionsRequestMapping(OperationInfo <Verb> operation, HttpUrl methodRoute, HttpStatusCode responseStatusCode, params string[] allowed) { if (operation == null) { throw new ArgumentNullException("operation"); } if (allowed == null) { throw new ArgumentNullException("allowed"); } if (allowed.Length == 0) { throw new ArgumentOutOfRangeException("allowed"); } Target = new OptionsController(responseStatusCode, allowed); Operation = operation; MethodRoute = methodRoute; ArgumentSources = new Dictionary <int, ArgumentValueSources>(operation.UnderlyingMethod.GetParameters().Length + (operation.UnderlyingMethod.ReturnType != typeof(void) ? 1 : 0)); }
/// <summary> /// 获得用户可操作权限 /// </summary> private void GetUserOpts(string strParent) { WebRequest webRequest = new WebRequest(); webRequest.Code = (int)RequestCode.WSGetUserOptList; webRequest.Session = App.Session; webRequest.ListData.Add(App.Session.UserID.ToString()); webRequest.ListData.Add("61"); webRequest.ListData.Add(strParent); Service11012Client client = new Service11012Client(WebHelper.CreateBasicHttpBinding(App.Session), WebHelper.CreateEndpointAddress(App.Session.AppServerInfo, "Service11012")); WebReturn webReturn = client.DoOperation(webRequest); App.MonitorHelper.AddWebReturn(webReturn); client.Close(); if (!webReturn.Result) { App.ShowExceptionMessage(string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message)); return; } for (int i = 0; i < webReturn.ListData.Count; i++) { OperationReturn optReturn = XMLHelper.DeserializeObject <OperationInfo>(webReturn.ListData[i]); if (!optReturn.Result) { App.ShowExceptionMessage(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message)); return; } OperationInfo optInfo = optReturn.Data as OperationInfo; if (optInfo != null) { optInfo.Display = App.GetLanguageInfo(string.Format("FO{0}", optInfo.ID), optInfo.ID.ToString()); optInfo.Description = optInfo.Display; AllListDashBoard.Add(optInfo); GetUserOpts(optInfo.ID.ToString()); } } }
public override void Process(byte[] array, OperationInfo info) { WriteByte(array, info, option); WriteShort(array, info, index); switch (option) { case 0: WriteShort(array, info, dx); WriteShort(array, info, dy); return; case 1: WriteShort(array, info, dx); WriteShort(array, info, dy); WriteShort(array, info, dWidth); WriteShort(array, info, dHeight); return; case 2: WriteShort(array, info, sx); WriteShort(array, info, sy); WriteShort(array, info, sWidth); WriteShort(array, info, sHeight); WriteShort(array, info, dx); WriteShort(array, info, dy); WriteShort(array, info, dWidth); WriteShort(array, info, dHeight); return; default: throw new Exception("DrawImageOperation Clown"); } }
private double GetMatchRank(ControllerInfo controller, OperationInfo <Verb> operation, IEnumerable <string> queryString, Verb method) { var requiredQueryStringArguments = new List <string>(); var optionalQueryStringArguments = new List <string>(); var matchingRequiredParameters = new List <string>(); var matchingOptionalParameters = new List <string>(); foreach (var argument in operation.Arguments.Where(argument => argument.Source is FromQueryStringAttribute)) { (argument.Parameter.HasDefaultValue ? optionalQueryStringArguments : requiredQueryStringArguments).Add(argument.VariableName); if (queryString.Contains(argument.VariableName, StringComparer.InvariantCultureIgnoreCase)) { (argument.Parameter.HasDefaultValue ? matchingOptionalParameters : matchingRequiredParameters).Add(argument.VariableName); } } var result = (controller.ControllerType.IsGenericType ? 0 : 1) + (operation.ProtocolSpecificCommand == method ? (VerbRanks.ContainsKey(method) ? VerbRanks[method] : VerbRanks[Verb.Empty]) : 0); result += Math.Max(0, matchingRequiredParameters.Count - requiredQueryStringArguments.Count) + (Math.Max(0, matchingOptionalParameters.Count - optionalQueryStringArguments.Count) * 10); return(result); }
public override void Process(byte[] array, OperationInfo info) { WriteByte(array, info, option); switch (option) { case 0: WriteString(array, info, color); return; case 1: throw new Exception("FillStyleOperation DontCare"); case 2: WriteShort(array, info, index); return; default: throw new Exception("FillStyleOperation Clown"); } }
/// <summary> /// Anade soporte para u operador binario /// </summary> /// <param name="other">Tipo del otro operando</param> /// <param name="resultType">Tipo del resultado de la operacion</param> /// <param name="op">Operador en cuestion</param> /// <param name="generator">Generador de codigo para la operacion</param> /// <param name="predefinedOp">Indica si es una operacion predefinida en el lenguaje</param> public void AddBinaryOperation(TigerType other, TigerType resultType, Operators op, GenOperation generator, bool predefinedOp) { // if ((int)op >= 10) // throw new InvalidOperationException("Operator " + op + " can not be defined for the given types"); var nfo = new OperationInfo { ResultType = resultType, Op1 = this, Op2 = other, CurrentOperator = op, GenOperation = generator, IsPredefinedOperation = predefinedOp }; string id = nfo.ToString(); if (operatorTable.ContainsKey(id)) { throw new InvalidOperationException("Operations can not be redefined"); } operatorTable.Add(id, nfo); }
public void TestProperties(OperationType operationType, int filesCount, int dirsCount, bool isProcessingSingleFile, OperationState operationState, string sourceFile) { var files = Enumerable .Repeat(File, filesCount) .ToArray(); var dirs = Enumerable .Repeat(Directory, dirsCount) .ToArray(); var settings = new BinaryFileSystemOperationSettings(dirs, files, dirs, files, new Dictionary <string, string>(0), new string[0], SourceDirectory, TargetDirectory); var operationInfo = new OperationInfo(operationType, settings); _autoMocker .Setup <IOperation, OperationInfo>(m => m.Info) .Returns(operationInfo); _autoMocker .Setup <IOperation, OperationState>(m => m.State) .Returns(operationState); _autoMocker .Setup <IPathService, string>(m => m.GetFileName(It.IsAny <string>())) .Returns <string>(s => s); var viewModel = _autoMocker.CreateInstance <OperationStateViewModel>(); Assert.Equal(0, viewModel.Progress); Assert.Equal(operationState, viewModel.State); Assert.Equal(filesCount, viewModel.SourceFilesCount); Assert.Equal(dirsCount, viewModel.SourceDirectoriesCount); Assert.Equal(isProcessingSingleFile, viewModel.IsProcessingSingleFile); Assert.Equal(operationType, viewModel.OperationType); Assert.Equal(sourceFile, viewModel.SourceFile); Assert.Equal(SourceDirectory, viewModel.SourceDirectory); Assert.Equal(TargetDirectory, viewModel.TargetDirectory); }
public override void Process(byte[] array, OperationInfo info) { WriteByte(array, info, dictIndex); switch (dictIndex) { case 0: case 1: case 2: { WriteByte(array, info, option); if (option == 0) { WriteString(array, info, value); } else { WriteShort(array, info, objIndex); } return; } case 3: { WriteBool(array, info, @bool); return; } case 4: { WriteByte(array, info, option); return; } } }
/// <summary> /// 获得用户可操作权限 /// </summary> private void GetUserOpts() { WebRequest webRequest = new WebRequest(); webRequest.Code = (int)RequestCode.WSGetUserOptList; webRequest.Session = CurrentApp.Session; webRequest.ListData.Add(CurrentApp.Session.UserID.ToString()); webRequest.ListData.Add("24"); webRequest.ListData.Add("2403"); Service11012Client client = new Service11012Client(WebHelper.CreateBasicHttpBinding(CurrentApp.Session), WebHelper.CreateEndpointAddress(CurrentApp.Session.AppServerInfo, "Service11012")); WebReturn webReturn = client.DoOperation(webRequest); CurrentApp.MonitorHelper.AddWebReturn(webReturn); client.Close(); if (!webReturn.Result) { ShowException(string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message)); return; } ListOperationsOnlyAdd.Clear(); AllListOperations.Clear(); for (int i = 0; i < webReturn.ListData.Count; i++) { OperationReturn optReturn = XMLHelper.DeserializeObject <OperationInfo>(webReturn.ListData[i]); if (!optReturn.Result) { ShowException(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message)); return; } OperationInfo optInfo = optReturn.Data as OperationInfo; if (optInfo != null) { AllListOperations.Add(optInfo); } } }
internal void Write(Action <DatabaseConnection> action) { OperationInfo info = null; #if DEBUG info = new OperationInfo { Thread = Thread.CurrentThread, StackTrace = Environment.StackTrace, RunAsMutating = true, }; this.addOngoingOperationInfo(info); #endif try { this.rwLock.EnterWriteLock(); action(this.mutatingConnection); } #if DEBUG catch (SQLite.SQLiteException e) { if (e.Result == SQLite3.Result.Busy) { Log.Error("SQLITE read encountered \"Busy\" during write operation, exception ({exception}), dumping env:", e); this.dumpOngoingOperations(); } throw e; } #endif finally { this.rwLock.ExitWriteLock(); this.removeOngoingOperationInfo(info); } }
private ReservationOrder BuildOrder() { bool surnameInvalid = string.IsNullOrEmpty(SurnameInput.InputText); bool nameInvalid = string.IsNullOrEmpty(NameInput.InputText); bool emailInvalid = string.IsNullOrEmpty(EmailInput.InputText); bool typeInvalid = OperationSelector.SelectedIndex == -1; if (surnameInvalid || nameInvalid || emailInvalid || typeInvalid) { MessageBox.Show("Invalid data"); return(null); } PlatformApiInfo platform = PlatformSelector.SelectedItem as PlatformApiInfo; CityPlatformInfo city = CitySelector.SelectedItem as CityPlatformInfo; OperationInfo operation = OperationSelector.SelectedItem as OperationInfo; ReservationOrder order = new ReservationOrder( SurnameInput.InputText, NameInput.InputText, EmailInput.InputText, platform.Name, city.Name, city.BaseUrl, operation ); return(order); }
// Context: async. // RunWorkerCompletedEventArgsWithUserState OperationHandler(OperationInfo opInfo) { object userState = opInfo.OperationRequest.UserState; DoWorkEventArgs eventArgs = new DoWorkEventArgs(userState); try { RaiseDoWorkEventFromAsyncContext(eventArgs); if (eventArgs.Cancel) { opInfo.OperationRequest.Cancel(); // For the sake of completeness. return(new RunWorkerCompletedEventArgsWithUserState(null, null, true, userState)); } else { return(new RunWorkerCompletedEventArgsWithUserState(eventArgs.Result, null, false, userState)); } } catch (Exception err) { return(new RunWorkerCompletedEventArgsWithUserState(null, err, false, userState)); } }
private object[] BindArguments(string callUri, MethodInfo method, Verb verb, bool indirectly = false) { var methodUri = Regex.Replace(callUri, "\\?.+", String.Empty); var queryStringParameters = Regex.Matches(callUri, "[?&]([^=]+)=[^&]+").Cast <System.Text.RegularExpressions.Match>(); var queryStringRegex = (queryStringParameters.Any() ? "[?&](" + String.Join("|", queryStringParameters.Select(item => item.Groups[1].Value)) + ")=[^&]+" : String.Empty); var arguments = method.GetParameters() .Select(item => new ArgumentInfo(item, FromQueryStringAttribute.For(item), "&test={?test}", "test")); var operation = new OperationInfo <Verb>( method, (HttpUrl)UrlParser.Parse(methodUri), callUri, new Regex("^" + methodUri + queryStringRegex + "$"), verb, arguments.ToArray()); var request = new RequestInfo(Verb.GET, (HttpUrl)UrlParser.Parse("http://temp.uri" + callUri), new MemoryStream(), new BasicClaimBasedIdentity()); var mapping = new RequestMapping(GetControllerInstance(), operation, (HttpUrl)UrlParser.Parse(methodUri)); if (indirectly) { return(_binder.BindArguments((IRequestInfo)request, (IRequestMapping)mapping)); } return(_binder.BindArguments(request, mapping)); }
private void InitBut1() { OperationBut.Children.Clear(); Button btn; OperationInfo opt; btn = new Button(); btn.Click += UpDateQuestion_Click; opt = new OperationInfo(); opt.Display = CurrentApp.GetLanguageInfo("3601T00137", "Change"); opt.Icon = "Images/add.png"; btn.DataContext = opt; btn.SetResourceReference(StyleProperty, "OptButtonStyle"); OperationBut.Children.Add(btn); btn = new Button(); btn.Click += NextQuestion_Click; opt = new OperationInfo(); opt.Display = CurrentApp.GetLanguageInfo("3601T00138", "Next"); opt.Icon = "Images/add.png"; btn.DataContext = opt; btn.SetResourceReference(StyleProperty, "OptButtonStyle"); OperationBut.Children.Add(btn); }
// Context: client. // public void RunWorkerAsync(object userState) { if (userState == null) { throw new ArgumentNullException("userState cannot be null."); } int prevCount; OperationRequest opRequest = new OperationRequest(userState, OperationHandler); OperationInfo opInfo = new OperationInfo(opRequest); lock (_collectionsLock) { if (_userStateToOperationMap.ContainsKey(userState)) { throw new InvalidOperationException("The specified userKey has already been used to identify a pending operation. Each userState parameter must be unique."); } // Make a note of the current pending queue size. If it's zero at this point, // we'll need to kick off an operation. // prevCount = _operationQueue.Count; // Place the new work item on the queue & also in the userState-to-OperationInfo map. // _operationQueue.Enqueue(opInfo); _userStateToOperationMap[userState] = opInfo; } if (prevCount == 0) { // We just queued up the first item - kick off the operation. // opRequest.OperationHandler.BeginInvoke(opInfo, OperationHandlerDone, opInfo); } }
private int InterimsFirst(OperationInfo x, OperationInfo y) { if (IsInterimCode(x.OperationCode) && IsInterimCode(y.OperationCode)) { return(x.OperationCode.CompareTo(y.OperationCode)); } if (!IsInterimCode(x.OperationCode) && !IsInterimCode(y.OperationCode)) { return(x.OperationCode.CompareTo(y.OperationCode)); } if (IsInterimCode(x.OperationCode) && !IsInterimCode(y.OperationCode)) { return(-1); } if (!IsInterimCode(x.OperationCode) && IsInterimCode(y.OperationCode)) { return(1); } return(0); }
private void PerformNode( BspNode inNode, Face inFace, int nodeSide, OperationInfo info ) { while( inNode != null ) { Face.EPlaneSide side = inFace.Side( inNode.plane ); switch( side ) { case Face.EPlaneSide.Side_Front: // nodeSide = nodeSide | (inNode.IsCsg() ? 1 : 0); // leaf node if( inNode.front == null ) { // set operation infos info.leafNode = inNode; info.leafLocation = BspNode.EBspLocation.BspLocation_Front; // we are done, process face ProcessFace( inFace, SIDE_Outside, info ); } // get to next front node (if any) inNode = inNode.front; break; case Face.EPlaneSide.Side_Back: int backSide = inNode.IsCsg() ? 0 : 1; // nodeSide = nodeSide & backSide; // leaf node if( inNode.back == null ) { // set leaf infos info.leafNode = inNode; info.leafLocation = BspNode.EBspLocation.BspLocation_Back; // we are done, process face ProcessFace( inFace, SIDE_Inside, info ); } // get to next front node (if any) inNode = inNode.back; break; case Face.EPlaneSide.Side_Split: // split face and process front and back Face frontFace, backFace; // inFace.Split( inNode.plane, out frontFace, out backFace ); // TODO: set polygon cutted flags frontFace.flags |= Face.FaceFlags_WasCutted; backFace.flags |= Face.FaceFlags_WasCutted; // front node is a leaf node if( inNode.front == null ) { // info.leafNode = inNode; info.leafLocation = BspNode.EBspLocation.BspLocation_Front; ProcessFace( frontFace, SIDE_Outside, info ); } else { PerformNode( inNode.front, frontFace, nodeSide, info ); } // Prcess back node with back face if( inNode.back == null ) { // info.leafNode = inNode; info.leafLocation = BspNode.EBspLocation.BspLocation_Back; ProcessFace( backFace, SIDE_Inside, info ); } else { // process back node with new face PerformNode( inNode.back, backFace, nodeSide, info ); } // stop loop inNode = null; break; case Face.EPlaneSide.Side_Planar: BspNode front, back; if( info.wasPlanar == true ) { Debug.Log( "Reentering Planar Nodes!" ); } // set operation infos info.wasPlanar = true; info.backNode = null; info.processingBack = false; if( Vector3.Dot( inFace.GetPlane().normal, inNode.plane.normal ) >= 0.0f ) { // same order as we face in the same order front = inNode.front; back = inNode.back; // we are for now outside (as we are looking outside) info.planarSide = SIDE_Outside; } else { // reverse order as we are facing in the opposite direction front = inNode.back; back = inNode.front; // we are now inside as we are looking to the inside info.planarSide = SIDE_Inside; } // we are leaf node (coplanar face) if( front == null && back == null ) { // set leaf stuff info.leafNode = inNode; info.leafLocation = BspNode.EBspLocation.BspLocation_Planar; // process node info.processingBack = true; // process face ProcessFace( inFace, InverseSide(info.planarSide), info ); // stop loop inNode = null; } else if( front == null && back != null ) { // only back nodes info.processingBack = true; // process back inNode = back; } else { // tread like we were on front side (maybe we do have a back node) info.processingBack = false; // remember back node info.backNode = back; // process front inNode = front; } break; } } }
private static void InitializeOper( out OperationInfo outInfo ) { outInfo.leafNode = null; outInfo.leafLocation = BspNode.EBspLocation.BspLocation_Planar; outInfo.wasPlanar = false; outInfo.processingBack = false; outInfo.backNode = null; outInfo.planarSide = SIDE_Outside; }
private string GetOrderGroupName(OperationInfo opInfo, string value) { string str = ""; if (opInfo == OperationInfo.order) { switch (value) { case "0": str = "常白"; break; case "1": str = "早"; break; case "2": str = "中"; break; case "3": str = "晚"; break; } } else if (opInfo == OperationInfo.group) { switch (value) { case "0": str = "常白"; break; case "1": str = "甲"; break; case "2": str = "乙"; break; case "3": str = "丙"; break; case "4": str = "丁"; break; } } return str; }
// private void ProcessFace( Face inFace, int inNodeSide, OperationInfo info ) { EPolySide polySide; // never on a planar node, really easy if( info.wasPlanar == false ) { // set polyside polySide = (inNodeSide == SIDE_Outside) ? EPolySide.PolySide_Outside : EPolySide.PolySide_Inside; // RouteOper( null, inFace, polySide, info ); } else if( info.processingBack ) { // if( inNodeSide == info.planarSide ) { polySide = (inNodeSide == SIDE_Inside) ? EPolySide.PolySide_Planar_Inside : EPolySide.PolySide_Planar_Outside; } else { polySide = (info.planarSide == SIDE_Inside) ? EPolySide.PolySide_CoPlanar_Inside : EPolySide.PolySide_CoPlanar_Outside; } RouteOper( null, inFace, polySide, info ); } else { // int backNodeSide = InverseSide(info.planarSide); // info.planarSide = inNodeSide; // back node is empty if( info.backNode == null ) { // back tree is empty inNodeSide = backNodeSide; // back node is empty if( inNodeSide == info.planarSide ) { polySide = (inNodeSide == SIDE_Inside) ? EPolySide.PolySide_Planar_Inside : EPolySide.PolySide_Planar_Outside; } else { polySide = (info.planarSide == SIDE_Inside) ? EPolySide.PolySide_CoPlanar_Inside : EPolySide.PolySide_CoPlanar_Outside; } RouteOper( null, inFace, polySide, info ); } else { info.processingBack = true; // TODO: conversion inNodeSide = backNodeSide; // PerformNode( info.backNode, inFace, inNodeSide, info ); } } }
public OperationServiceThread(OperationInfo info) { this.Info = info; }
private IIriTemplateMapping BuildTemplateMapping(DescriptionContext context, Uri templateUri, OperationInfo<Verb> operation, ArgumentInfo mapping) { IIriTemplateMapping templateMapping = context.ApiDocumentation.Context.Create<IIriTemplateMapping>(templateUri.AddFragment(mapping.VariableName)); templateMapping.Variable = mapping.VariableName; templateMapping.Required = (mapping.Parameter.ParameterType.IsValueType) && (!mapping.Parameter.HasDefaultValue); templateMapping.Description = _xmlDocProvider.GetDescription(operation.UnderlyingMethod, mapping.Parameter); var linqBehaviors = mapping.Parameter.GetCustomAttributes<LinqServerBehaviorAttribute>(true); if (linqBehaviors.Any()) { foreach (var visitor in _serverBehaviorAttributeVisitors) { linqBehaviors.Accept(mapping.Parameter.ParameterType, visitor, templateMapping, context); } } else if (context.Type != typeof(object)) { templateMapping.Property = GetMappingProperty(context, mapping.Parameter); } return templateMapping; }
static OperationInfoTS OnAddOperationExtension(OperationInfoTS oi, OperationInfo o) { if (AddOperationExtension == null) return oi; foreach (var a in AddOperationExtension.GetInvocationListTyped()) a(oi, o); return oi; }
private static void BuildOperationMediaType(IOperation result, IEnumerable<IClass> resources, OperationInfo operation, bool requiresRdf) { foreach (var resource in resources) { foreach (var mediaType in operation.UnderlyingMethod.GetCustomAttributes<AsMediaTypeAttribute>()) { result.MediaTypes.Add(mediaType.MediaType); } if (result.MediaTypes.Count != 0) { continue; } BuildOperationMediaType(result, requiresRdf); } }
private IOperation BuildOperation(DescriptionContext context, OperationInfo<Verb> operation, out IIriTemplate template) { IOperation result = operation.AsOperation(context.ApiDocumentation); result.Label = operation.UnderlyingMethod.Name; result.Description = _xmlDocProvider.GetDescription(operation.UnderlyingMethod); result.Method.Add(operation.ProtocolSpecificCommand.ToString()); template = BuildTemplate(context, operation, result); bool requiresRdf = context.RequiresRdf(SpecializationType); bool isRdfRequired = requiresRdf; var arguments = operation.Arguments.Where(parameter => parameter.Source is FromBodyAttribute).Select(parameter => parameter.Parameter); var results = operation.Results.Where(output => output.Target is ToBodyAttribute).Select(parameter => parameter.Parameter); foreach (var value in arguments) { var expected = (context.ContainsType(value.ParameterType) ? context[value.ParameterType] : context.ForType(value.ParameterType).BuildTypeDescription(out isRdfRequired)); expected = context.SubClass(expected, value.ParameterType); expected.Label = value.Name ?? "instance"; expected.Description = _xmlDocProvider.GetDescription(operation.UnderlyingMethod, value); result.Expects.Add(expected); requiresRdf |= isRdfRequired; } foreach (var value in results) { var returned = (context.ContainsType(value.ParameterType) ? context[value.ParameterType] : context.ForType(value.ParameterType).BuildTypeDescription(out isRdfRequired)); returned = context.SubClass(returned, value.ParameterType); returned.Description = _xmlDocProvider.GetDescription(operation.UnderlyingMethod, value); result.Returns.Add(returned); requiresRdf |= isRdfRequired; } BuildStatusCodes(result, operation); BuildOperationMediaType(result, result.Returns, operation, requiresRdf); BuildOperationMediaType(result, result.Expects, operation, requiresRdf); if (!result.MediaTypes.Any()) { BuildOperationMediaType(result, requiresRdf); } return result; }
private void BuildStatusCodes(IOperation result, OperationInfo<Verb> operation) { result.StatusCodes.AddRange( operation.UnderlyingMethod.DiscoverCrudStatusCodeNumbers(operation.ProtocolSpecificCommand, operation.Controller.ControllerType) .Union( from exceptionTypeName in _xmlDocProvider.GetExceptions(operation.UnderlyingMethod) select (int)exceptionTypeName.ToHttpStatusCode()) .Union( from claimType in operation.UnifiedSecurityRequirements.Denied select (int)(claimType == ClaimTypes.Anonymous ? HttpStatusCode.Unauthorized : HttpStatusCode.Forbidden)) .Union( from claimType in operation.UnifiedSecurityRequirements.Allowed where claimType != ClaimTypes.Anonymous select (int)HttpStatusCode.Forbidden) .Distinct()); }
private IIriTemplate BuildTemplate(DescriptionContext context, OperationInfo<Verb> operation, IOperation operationDocumentation) { IEnumerable<ArgumentInfo> parameterMapping; var uriTemplate = _descriptionBuilder.GetOperationUrlTemplate(operation.UnderlyingMethod, out parameterMapping); if (String.IsNullOrEmpty(uriTemplate)) { return null; } IIriTemplate template = null; var templateUri = operationDocumentation.Id.Uri.AddFragment("template"); var templateMappings = from mapping in parameterMapping where !(mapping.Source is FromBodyAttribute) select BuildTemplateMapping(context, templateUri, operation, mapping); foreach (var templateMapping in templateMappings) { if (template == null) { template = context.ApiDocumentation.Context.Create<IIriTemplate>(templateUri); template.Template = uriTemplate; } template.Mappings.Add(templateMapping); } return template; }
public OperationInfoTS(OperationInfo oper) { this.AllowsNew = oper.AllowsNew; this.HasCanExecute = oper.HasCanExecute; this.HasStates = oper.HasStates; this.OperationType = oper.OperationType; this.Lite = oper.Lite; }
void ImportMessageContract() { if (contractContext.Contract.Operations.Count <= 0) return; CurrentSchemaImporter.PreprocessSchema(); bool importerUsed = true; OperationInfo[] infos = new OperationInfo[contractContext.Contract.Operations.Count]; int i = 0; foreach (OperationDescription operation in contractContext.Contract.Operations) { OperationInfo operationInfo; if (!CanImportOperation(operation, out operationInfo)) { TraceImportInformation(operation); importerUsed = false; break; } infos[i++] = operationInfo; } if (importerUsed) { i = 0; foreach (OperationDescription operation in contractContext.Contract.Operations) { ImportOperationContract(operation, infos[i++]); } } CurrentSchemaImporter.PostprocessSchema(importerUsed); }
private object[] BindArguments(string callUri, MethodInfo method, Verb verb, bool indirectly = false) { var methodUri = Regex.Replace(callUri, "\\?.+", String.Empty); var queryStringParameters = Regex.Matches(callUri, "[?&]([^=]+)=[^&]+").Cast<System.Text.RegularExpressions.Match>(); var queryStringRegex = (queryStringParameters.Any() ? "[?&](" + String.Join("|", queryStringParameters.Select(item => item.Groups[1].Value)) + ")=[^&]+" : String.Empty); var arguments = method.GetParameters() .Select(item => new ArgumentInfo(item, FromQueryStringAttribute.For(item), "&test={?test}", "test")); var operation = new OperationInfo<Verb>( method, (HttpUrl)UrlParser.Parse(methodUri), callUri, new Regex("^" + methodUri + queryStringRegex + "$"), verb, arguments.ToArray()); var request = new RequestInfo(Verb.GET, (HttpUrl)UrlParser.Parse("http://temp.uri" + callUri), new MemoryStream(), new BasicClaimBasedIdentity()); var mapping = new RequestMapping(GetControllerInstance(), operation, (HttpUrl)UrlParser.Parse(methodUri)); if (indirectly) { return _binder.BindArguments((IRequestInfo)request, (IRequestMapping)mapping); } return _binder.BindArguments(request, mapping); }
public void Teardown() { _controller = null; _operation = null; _delegateMapper = null; }
bool CanImportOperation(OperationDescription operation, out OperationInfo operationInfo) { operationInfo = null; if (OperationHasBeenHandled(operation)) return false; WsdlNS.Operation wsdlOperation = contractContext.GetOperation(operation); Collection<WsdlNS.OperationBinding> wsdlOperationBindings = contractContext.GetOperationBindings(wsdlOperation); return CanImportOperation(operation, wsdlOperation, wsdlOperationBindings, out operationInfo) && CanImportFaults(wsdlOperation, operation); }
public void Setup() { var method = typeof(TestController).GetMethod("Add"); var baseUri = (HttpUrl)UrlParser.Parse("/api/test/"); var operationUri = ((HttpUrl)UrlParser.Parse("/add")).InsertSegments(0, baseUri.Segments); var operation = new OperationInfo<Verb>( method, operationUri, operationUri + "?operandA={?operandA}&operandB={?operandB}", new Regex(operationUri.ToString(), RegexOptions.IgnoreCase), Verb.GET, new ArgumentInfo(method.GetParameters()[0], FromQueryStringAttribute.For(method.GetParameters()[0]), "&operandA={?operandA}", "operandA"), new ArgumentInfo(method.GetParameters()[1], FromQueryStringAttribute.For(method.GetParameters()[1]), "&operandB={?operandB}", "operandB")); var description = new ControllerInfo<TestController>(null, (HttpUrl)UrlParser.Parse("/api/test/"), operation); Mock<IHttpControllerDescriptionBuilder<TestController>> builder = new Mock<IHttpControllerDescriptionBuilder<TestController>>(); builder.As<IControllerDescriptionBuilder>().Setup(instance => instance.BuildDescriptor()).Returns(description); Mock<IControllerActivator> activator = new Mock<IControllerActivator>(); activator.Setup(instance => instance.CreateInstance(It.IsAny<Type>(), It.IsAny<IDictionary<string, object>>())).Returns(new TestController()); _mapper = new DelegateMapper(new IHttpControllerDescriptionBuilder[] { builder.Object }, activator.Object); }
void ImportOperationContract(OperationDescription operation, OperationInfo operationInfo) { Fx.Assert(!OperationHasBeenHandled(operation), ""); Fx.Assert(operationInfo != null, ""); WsdlNS.Operation wsdlOperation = contractContext.GetOperation(operation); Collection<WsdlNS.OperationBinding> wsdlOperationBindings = contractContext.GetOperationBindings(wsdlOperation); bool isReply = false; foreach (WsdlNS.OperationMessage operationMessage in wsdlOperation.Messages) { ImportMessage(operationMessage, isReply, operationInfo.IsEncoded, operationInfo.AreAllMessagesWrapped); isReply = true; } if (operationInfo.Style == OperationFormatStyle.Rpc) SetWrapperName(operation); this.CurrentSchemaImporter.SetOperationStyle(operation, operationInfo.Style); this.CurrentSchemaImporter.SetOperationIsEncoded(operation, operationInfo.IsEncoded); this.CurrentSchemaImporter.SetOperationSupportFaults(operation, this.faultImportOptions.UseMessageFormat); ImportFaults(wsdlOperation, operation, operationInfo.IsEncoded); foreach (WsdlNS.OperationBinding wsdlOperationBinding in wsdlOperationBindings) { foreach (MessageDescription message in operation.Messages) { WsdlNS.OperationMessage wsdlOperationMessage = contractContext.GetOperationMessage(message); WsdlNS.ServiceDescriptionCollection wsdlDocuments = wsdlOperationMessage.Operation.PortType.ServiceDescription.ServiceDescriptions; WsdlNS.Message wsdlMessage = wsdlDocuments.GetMessage(wsdlOperationMessage.Message); WsdlNS.MessageBinding messageBinding = (message.Direction == MessageDirection.Input) ? (WsdlNS.MessageBinding)wsdlOperationBinding.Input : (WsdlNS.MessageBinding)wsdlOperationBinding.Output; if (messageBinding != null) ImportMessageBinding(messageBinding, wsdlMessage, message, operationInfo.Style, operationInfo.IsEncoded); } } operation.Behaviors.Add(CurrentSchemaImporter.GetOperationGenerator()); }
public OperationItemViewModel(ReactiveProperty<ObservablePhotonPeer> peer, ReactiveProperty<string> log, OperationInfo info) { Info = info; ParameterItems = info.FlatternedParameters .Select(x => { var piv = new ParameterItemViewModel { Name = x.Name, TypeName = x.TypeName, Comment = x.Comment, IsNeedTemplate = x.IsNeedTemplate, InsertButtonVisibility = x.IsNeedTemplate ? Visibility.Visible : Visibility.Hidden, Template = (x.IsNeedTemplate) ? x.Template : null }; if (x.DefaultValue != null) piv.ParameterValue.Value = x.DefaultValue.ToString(); return piv; }) .ToArray(); CopyCommand = new ReactiveCommand(Observable.Return(ParameterItems.Any())); CopyCommand.Subscribe(_ => { var data = new ClipboardData { HubName = Info.Hub.HubName, OperationName = Info.OperationName, Data = ParameterItems.Select(x => x.ParameterValue.Value).ToArray() }; var value = JsonConvert.SerializeObject(data); Clipboard.SetText(value, TextDataFormat.UnicodeText); }); if (!ParameterItems.Any()) { PasteCommand = new ReactiveCommand(Observable.Return(false)); } else { PasteCommand = ClipboardMonitor.CurrentClipboard .Select(text => { try { if (text.Contains(nameof(ClipboardData.HubName)) && text.Contains(nameof(ClipboardData.OperationName))) { var cd = JsonConvert.DeserializeObject<ClipboardData>(text); if (cd.HubName == Info.Hub.HubName && cd.OperationName == Info.OperationName) return true; } return false; } catch { return false; } }) .ToReactiveCommand(initialValue: false); PasteCommand.Subscribe(_ => { try { if (Clipboard.ContainsText(TextDataFormat.UnicodeText)) { var text = Clipboard.GetText(); var cd = JsonConvert.DeserializeObject<ClipboardData>(text); var index = 0; foreach (var item in cd.Data) { ParameterItems[index].ParameterValue.Value = item; index++; } } } catch { } }); } SendCommand = new ReactiveCommand(); SendCommand.Subscribe(async _ => { try { byte opCode = Info.OperationId; var parameter = new System.Collections.Generic.Dictionary<byte, object>(); parameter.Add(ReservedParameterNo.RequestHubId, Info.Hub.HubId); // grouping var grouping = ParameterItems.GroupBy(x => { var split = x.Name.Split('.'); return split[0]; }); var index = 0; foreach (var item in grouping) { if (item.Count() == 1) { var p = item.First(); parameter.Add((byte)index, JsonPhotonSerializer.Serialize(p.TypeName, p.ParameterValue.Value)); } else { // Object var p = BuildJson(item); parameter.Add((byte)index, Encoding.UTF8.GetBytes(p)); // send byte[] } index++; } var response = await peer.Value.OpCustomAsync(opCode, parameter, true); var result = response[ReservedParameterNo.ResponseId]; var deserialized = JsonPhotonSerializer.Deserialize(result); log.Value += "+ " + Info.Hub.HubName + "/" + Info.OperationName + ":" + deserialized + "\r\n"; } catch (Exception ex) { log.Value += "Send Error:" + ex.ToString() + "\r\n"; } }); }
bool CanImportOperation(OperationDescription operation, WsdlNS.Operation wsdlOperation, Collection<WsdlNS.OperationBinding> operationBindings, out OperationInfo operationInfo) { operationInfo = null; OperationFormatStyle style = OperationFormatStyle.Document; bool isEncoded = false; bool areAllMessagesWrapped = true; // Check if operation bindings can be imported StyleAndUse? styleAndUse = null; WsdlNS.ServiceDescriptionCollection documents = wsdlOperation.PortType.ServiceDescription.ServiceDescriptions; WsdlNS.OperationBinding prevOperationBinding = null; foreach (WsdlNS.OperationBinding operationBinding in operationBindings) { OperationFormatStyle operationStyle = GetStyle(operationBinding); bool? isOperationEncoded = null; foreach (MessageDescription message in operation.Messages) { WsdlNS.OperationMessage operationMessage = contractContext.GetOperationMessage(message); if (operationMessage.Message.IsEmpty) { if (operationMessage is WsdlNS.OperationInput) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.SFxWsdlOperationInputNeedsMessageAttribute2, wsdlOperation.Name, wsdlOperation.PortType.Name))); if (operationMessage is WsdlNS.OperationOutput) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.SFxWsdlOperationOutputNeedsMessageAttribute2, wsdlOperation.Name, wsdlOperation.PortType.Name))); } WsdlNS.Message wsdlMessage = documents.GetMessage(operationMessage.Message); if (wsdlMessage != null) { WsdlNS.MessageBinding messageBinding = (message.Direction == MessageDirection.Input) ? (WsdlNS.MessageBinding)operationBinding.Input : (WsdlNS.MessageBinding)operationBinding.Output; if (messageBinding != null) { bool isMessageEncoded; if (!CanImportMessageBinding(messageBinding, wsdlMessage, operationStyle, out isMessageEncoded)) return false; if (isOperationEncoded == null) isOperationEncoded = isMessageEncoded; else if (isOperationEncoded != isMessageEncoded) AddError(SR.GetString(SR.SFxInconsistentWsdlOperationUseInBindingMessages, messageBinding.OperationBinding.Name, messageBinding.OperationBinding.Binding.Name)); } } } foreach (WsdlNS.FaultBinding faultBinding in operationBinding.Faults) { bool isFaultEncoded; if (!CanImportFaultBinding(faultBinding, operationStyle, out isFaultEncoded)) return false; if (isOperationEncoded == null) isOperationEncoded = isFaultEncoded; else if (isOperationEncoded != isFaultEncoded) AddError(SR.GetString(SR.SFxInconsistentWsdlOperationUseInBindingFaults, faultBinding.OperationBinding.Name, faultBinding.OperationBinding.Binding.Name)); } isOperationEncoded = isOperationEncoded ?? false; if (styleAndUse == null) { styleAndUse = GetStyleAndUse(operationStyle, isOperationEncoded.Value); style = operationStyle; isEncoded = isOperationEncoded.Value; prevOperationBinding = operationBinding; } else { StyleAndUse operationStyleAndUse = GetStyleAndUse(operationStyle, isOperationEncoded.Value); if (operationStyleAndUse != styleAndUse) { AddError(SR.GetString(SR.SFxInconsistentWsdlOperationUseAndStyleInBinding, operation.Name, operationBinding.Binding.Name, GetUse(operationStyleAndUse), GetStyle(operationStyleAndUse), prevOperationBinding.Binding.Name, GetUse(styleAndUse.Value), GetStyle(styleAndUse.Value))); } if (operationStyleAndUse < styleAndUse) { styleAndUse = operationStyleAndUse; style = operationStyle; isEncoded = isOperationEncoded.Value; prevOperationBinding = operationBinding; } } } // Check if operation can be imported OperationFormatStyle? inferredOperationStyle = null; foreach (WsdlNS.OperationMessage wsdlOperationMessage in wsdlOperation.Messages) { if (wsdlOperationMessage.Message.IsEmpty) { if (wsdlOperationMessage is WsdlNS.OperationInput) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.SFxWsdlOperationInputNeedsMessageAttribute2, wsdlOperation.Name, wsdlOperation.PortType.Name))); if (wsdlOperationMessage is WsdlNS.OperationOutput) throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.SFxWsdlOperationOutputNeedsMessageAttribute2, wsdlOperation.Name, wsdlOperation.PortType.Name))); } WsdlNS.Message wsdlMessage = documents.GetMessage(wsdlOperationMessage.Message); OperationFormatStyle? inferredMessageStyle; if (!CanImportMessage(wsdlMessage, wsdlOperationMessage.Name, out inferredMessageStyle, ref areAllMessagesWrapped)) return false; if (wsdlMessage.Parts.Count > 0) { if (inferredOperationStyle == null || (inferredMessageStyle != null && inferredMessageStyle != inferredOperationStyle && inferredMessageStyle.Value == OperationFormatStyle.Document)) { inferredOperationStyle = inferredMessageStyle; } } } // Verify that information in operation bindings and operation match if (styleAndUse == null) style = inferredOperationStyle ?? OperationFormatStyle.Document; else if (inferredOperationStyle != null) { if (inferredOperationStyle.Value != style && inferredOperationStyle.Value == OperationFormatStyle.Document) AddError(SR.GetString(SR.SFxInconsistentWsdlOperationStyleInOperationMessages, operation.Name, inferredOperationStyle, style)); } operationInfo = new OperationInfo(style, isEncoded, areAllMessagesWrapped); return true; }
/// <summary> /// Returns the original shell for the Kata's answer in the workspace for the given userAnswer. /// It does this by finding another operation with the same name as the `userAnswer` but in the /// Kata's namespace /// </summary> public virtual OperationInfo FindRawAnswer(OperationInfo kata, OperationInfo userAnswer) => Resolver.Resolve($"{kata.Header.QualifiedName.Namespace.Value}.{userAnswer.FullName}");
/// <summary> /// Returns the original shell for the test's answer in the workspace for the given userAnswer. /// It does this by finding another operation with the same name as the `userAnswer` but in the /// test's namespace /// </summary> public virtual OperationInfo FindSkeletonAnswer(OperationInfo test, string userAnswer) => Resolver.Resolve($"{test.Header.QualifiedName.Namespace}.{userAnswer}");
internal IResource DetermineOperationOwner(OperationInfo<Verb> operation, DescriptionContext context, IClass specializationType) { IResource result = specializationType; PropertyInfo matchingProperty; if ((!typeof(IReadController<,>).IsAssignableFromSpecificGeneric(_descriptionBuilder.BuildDescriptor().ControllerType)) || ((matchingProperty = operation.UnderlyingMethod.MatchesPropertyOf(context.Type, typeof(IControlledEntity<>).GetProperties().First().Name)) == null)) { return result; } var propertyId = context.TypeDescriptionBuilder.GetSupportedPropertyId(matchingProperty, context.Type); return context.ApiDocumentation.Context.Load<ISupportedProperty>(propertyId); }
// void RouteOper( BspNode inNode, Face inFace, EPolySide inSide, OperationInfo info ) { if( processState == EProcessState.Process_Master ) { csgVisitor.ProcessMaster( this, inFace, inSide, info ); } else { csgVisitor.ProcessSlave( this, inFace, inSide, info ); } }
public override void Process(byte[] array, OperationInfo info) { WriteShort(array, info, width); WriteShort(array, info, height); }
internal IDictionary<XName, ContractDescription> GetContractDescriptions() { if (this.cachedInferredContracts == null) { this.WalkActivityTree(); this.correlationQueryByContract = new Dictionary<XName, Collection<CorrelationQuery>>(); IDictionary<XName, ContractDescription> dictionary = new Dictionary<XName, ContractDescription>(); IDictionary<ContractAndOperationNameTuple, OperationInfo> dictionary2 = new Dictionary<ContractAndOperationNameTuple, OperationInfo>(); foreach (Receive receive in this.knownServiceActivities) { OperationInfo info; XName serviceContractXName = this.FixServiceContractName(receive.ServiceContractName); ContractAndOperationNameTuple key = new ContractAndOperationNameTuple(serviceContractXName, receive.OperationName); if (dictionary2.TryGetValue(key, out info)) { ContractValidationHelper.ValidateReceiveWithReceive(receive, info.Receive); } else { ContractDescription description; if (!dictionary.TryGetValue(serviceContractXName, out description)) { description = new ContractDescription(serviceContractXName.LocalName, serviceContractXName.NamespaceName) { ConfigurationName = serviceContractXName.LocalName }; dictionary.Add(serviceContractXName, description); } OperationDescription item = ContractInferenceHelper.CreateOperationDescription(receive, description); description.Operations.Add(item); info = new OperationInfo(receive, item); dictionary2.Add(key, info); } this.CorrectOutMessageForOperationWithFault(receive, info); ContractInferenceHelper.UpdateIsOneWayFlag(receive, info.OperationDescription); ContractInferenceHelper.AddFaultDescription(receive, info.OperationDescription); ContractInferenceHelper.AddKnownTypesToOperation(receive, info.OperationDescription); ContractInferenceHelper.AddReceiveToFormatterBehavior(receive, info.OperationDescription); Collection<CorrelationQuery> queries = null; if (receive.HasCorrelatesOn || receive.HasCorrelationInitializers) { MessageQuerySet select = receive.HasCorrelatesOn ? receive.CorrelatesOn : null; CorrelationQuery correlationQuery = ContractInferenceHelper.CreateServerCorrelationQuery(select, receive.CorrelationInitializers, info.OperationDescription, false); this.CollectCorrelationQuery(ref queries, serviceContractXName, correlationQuery); } if (receive.HasReply) { foreach (SendReply reply in receive.FollowingReplies) { ReceiveAndReplyTuple tuple2 = new ReceiveAndReplyTuple(receive, reply); this.receiveAndReplyPairs.Remove(tuple2); this.CollectCorrelationQueryFromReply(ref queries, serviceContractXName, reply, info.OperationDescription); reply.SetContractName(serviceContractXName); } } if (receive.HasFault) { foreach (Activity activity in receive.FollowingFaults) { ReceiveAndReplyTuple tuple3 = new ReceiveAndReplyTuple(receive, activity); this.receiveAndReplyPairs.Remove(tuple3); this.CollectCorrelationQueryFromReply(ref queries, serviceContractXName, activity, info.OperationDescription); } } } if (this.receiveAndReplyPairs.Count != 0) { throw System.ServiceModel.Activities.FxTrace.Exception.AsError(new ValidationException(System.ServiceModel.Activities.SR.DanglingReceive)); } if (System.ServiceModel.Activities.TD.InferredContractDescriptionIsEnabled()) { foreach (ContractDescription description3 in dictionary.Values) { System.ServiceModel.Activities.TD.InferredContractDescription(description3.Name, description3.Namespace); if (System.ServiceModel.Activities.TD.InferredOperationDescriptionIsEnabled()) { foreach (OperationDescription description4 in description3.Operations) { System.ServiceModel.Activities.TD.InferredOperationDescription(description4.Name, description3.Name, description4.IsOneWay.ToString()); } } } } this.cachedInferredContracts = dictionary; } return this.cachedInferredContracts; }
/// <summary> /// Returns the reference implementation for the test's answer in the workspace for the given userAnswer. /// It does this by finding another operation with the same name as the `userAnswer` but in the /// test's namespace and with <c>_Reference</c> added to the userAnswer's name. /// </summary> public virtual OperationInfo FindReferenceImplementation(OperationInfo test, string userAnswer) => Resolver.Resolve($"{test.Header.QualifiedName.Namespace}.{userAnswer}_Reference");
public string GetOrderGroupName(OperationInfo opInfo, string value) { string str = ""; if (opInfo == OperationInfo.order) { switch (value) { case "0": str = "常白班"; break; case "1": str = "早班"; break; case "2": str = "中班"; break; case "3": str = "晚班"; break; } } else if (opInfo == OperationInfo.group) { switch (value) { case "0": str = "常白班"; break; case "1": str = "甲班"; break; case "2": str = "乙班"; break; case "3": str = "丙班"; break; case "4": str = "丁班"; break; } } return str; }