[System.Security.SecurityCritical] // auto-generated public virtual RealProxy CreateProxy(ObjRef objRef, Type serverType, Object serverObject, Context serverContext) { RemotingProxy rp = new RemotingProxy(serverType); // If this is a serverID, set the native context field in the TP if (null != serverContext) { RealProxy.SetStubData(rp, serverContext.InternalContextID); } if (objRef != null && objRef.GetServerIdentity().IsAllocated) { rp.SetSrvInfo(objRef.GetServerIdentity(), objRef.GetDomainID()); } // Set the flag indicating that the fields of the proxy // have been initialized rp.Initialized = true; // Sanity check Type t = serverType; if (!t.IsContextful && !t.IsMarshalByRef && (null != serverContext)) { throw new RemotingException( Environment.GetResourceString( "Remoting_Activation_MBR_ProxyAttribute")); } return rp; }
public virtual RealProxy CreateProxy(ObjRef objRef, Type serverType, Object serverObject, Context serverContext) { // TODO return null; }
public static string formatInContentLinks(string str, string regex, HtmlHelper html, IEnumerable<ILink> targets, int? returnProjectID = null, int? returnClientID = null) { var match = Regex.Match(str, regex); bool atStart = (match.Success && match.Index == 0); var regexSplit = Regex.Split(str, regex); var sb = new StringBuilder(); var or = new ObjRef(); Step nextStep; if (atStart) nextStep = Step.ID; else nextStep = Step.Content; for (var i = 0; i < regexSplit.Length; i++) { switch (nextStep) { case Step.Content: sb.Append(regexSplit[i]); nextStep = Step.ID; or = new ObjRef(); break; case Step.ID: int temp; if (int.TryParse(regexSplit[i], out temp) && targets.Any(s => s.LinkID == temp)) { or.Obj = targets.Single(s => s.LinkID == temp); } nextStep = Step.Text; break; case Step.Text: or.Text = regexSplit[i]; nextStep = Step.Content; if (or.Obj != null && html != null) { sb.Append(html.DetailLink(or.Obj, tip: TipType.After, linkText: string.IsNullOrEmpty(or.Text) ? or.Obj.LinkName : or.Text, returnProjectID: returnProjectID, returnClientID: returnClientID)); } else { sb.Append(or.Text); } break; } } return sb.ToString(); }
public static object Unmarshal(ObjRef objectRef) { }
/// <summary> /// 将远程代理取消远程共享 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="objRef"></param> public static void UnsetRemoteSharedObject <T>(ObjRef objRef) { RemotingServices.Unmarshal(objRef); }
public void MarshaledObject(object obj, ObjRef or) { }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { GetObject go = new GetObject(); go.SetCommandPrompt("Select surfaces, polysurfaces, or meshes"); go.GeometryFilter = ObjectType.Surface | ObjectType.PolysrfFilter | ObjectType.Mesh; go.GroupSelect = true; go.SubObjectSelect = false; go.GetMultiple(1, 0); if (go.CommandResult() != Result.Success) { return(go.CommandResult()); } List <Mesh> InMeshes = new List <Mesh>(go.ObjectCount); List <RhinoObject> InMeshObjects = new List <RhinoObject>(go.ObjectCount); List <RhinoObject> InObjects = new List <RhinoObject>(go.ObjectCount); for (int i = 0; i < go.ObjectCount; i++) { ObjRef objRef = go.Object(i); Mesh mesh = objRef.Mesh(); if (null == mesh) { InObjects.Add(objRef.Object()); } else { InMeshes.Add(mesh); InMeshObjects.Add(objRef.Object()); } } ObjRef[] meshRefs = null; if (InObjects.Count > 0) { meshRefs = RhinoObject.GetRenderMeshes(InObjects, true, false); if (null != meshRefs) { for (int i = 0; i < meshRefs.Length; i++) { Mesh mesh = meshRefs[i].Mesh(); if (null != mesh) { InMeshes.Add(mesh); } } } } RhinoViewport vp = doc.Views.ActiveView.ActiveViewport; for (int i = 0; i < InMeshes.Count; i++) { Polyline[] plines = InMeshes[i].GetOutlines(vp); if (null != plines) { for (int j = 0; j < plines.Length; j++) { Rhino.Geometry.PolylineCurve plineCrv = new PolylineCurve(plines[j]); plineCrv.RemoveShortSegments(RhinoMath.SqrtEpsilon); if (plineCrv.IsValid) { Guid objId = doc.Objects.AddCurve(plineCrv); RhinoObject obj = doc.Objects.Find(objId); if (null != obj) { obj.Select(true); } } } } } for (int i = 0; i < InObjects.Count; i++) { InObjects[i].Select(false); } for (int i = 0; i < InMeshObjects.Count; i++) { InMeshObjects[i].Select(false); } doc.Views.Redraw(); return(Result.Success); }
public void MarshaledObject(object obj, ObjRef or) { // TODO: Add TestServer.MarshaledObject implementation }
public static NErrorCode EntityInnerSimplified(ObjRef exprPtr, ref ObjRef res) => ExceptionEncode(ref res, exprPtr, exprPtr => exprPtr.AsEntity.InnerSimplified );
public IntermediaryObjRef(MarshalByRefObject mbro, Type reqtype, RealProxy pxy) : base(mbro, reqtype) { _custom = pxy.CreateObjRef(reqtype); }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { GetObject go = new GetObject(); go.SetCommandPrompt("Select mesh faces to delete"); go.GeometryFilter = ObjectType.MeshFace; go.GetMultiple(1, 0); if (go.CommandResult() != Result.Success) { return(go.CommandResult()); } List <FaceInfo> face_list = new List <FaceInfo>(go.ObjectCount); for (int i = 0; i < go.ObjectCount; i++) { ObjRef obj_ref = go.Object(i); MeshObject obj = obj_ref.Object() as Rhino.DocObjects.MeshObject; if (null == obj) { return(Result.Failure); } FaceInfo fi = new FaceInfo(); fi.m_obj = obj; fi.m_idx = obj_ref.GeometryComponentIndex.Index; face_list.Add(fi); } face_list.Sort(CompareFaceInfo); List <int> face_indices = new List <int>(); int idx = 1; Mesh new_mesh = null; MeshObject next_obj = null; MeshObject curr_obj = face_list[0].m_obj; face_indices.Add(face_list[0].m_idx); while (idx < face_list.Count) { next_obj = face_list[idx].m_obj; if (curr_obj.RuntimeSerialNumber == next_obj.RuntimeSerialNumber) { face_indices.Add(face_list[idx].m_idx); curr_obj = next_obj; idx++; continue; } new_mesh = curr_obj.MeshGeometry.DuplicateMesh(); face_indices.Sort(); new_mesh.Faces.DeleteFaces(face_indices); new_mesh.Compact(); doc.Objects.Replace(curr_obj.Id, new_mesh); face_indices.Clear(); face_indices.Add(face_list[idx].m_idx); curr_obj = next_obj; idx++; } new_mesh = curr_obj.MeshGeometry.DuplicateMesh(); face_indices.Sort(); new_mesh.Faces.DeleteFaces(face_indices); new_mesh.Compact(); doc.Objects.Replace(curr_obj.Id, new_mesh); doc.Views.Redraw(); return(Result.Success); }
public virtual RealProxy CreateProxy(ObjRef objRef, Type serverType, object serverObject, Context serverContext) { return(RemotingServices.GetRealProxy(RemotingServices.GetProxyForRemoteObject(objRef, serverType))); }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { // Open file dialog OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.InitialDirectory = doc.Path; openFileDialog.Filter = "3dm files (*.3dm)|*.3dm| dxf files (*.dxf)|*.dxf|All files (*.*)|*.*"; openFileDialog.FilterIndex = 2; openFileDialog.RestoreDirectory = true; openFileDialog.Multiselect = true; openFileDialog.Title = "CAD files to merge"; DialogResult dr = openFileDialog.ShowDialog(); uint firstSN, lastSN; string sScript; BoundingBox bbox; string panelDetails = ""; double importMinX, importMinY; double importMaxX, importMaxY; double globalMinX, globalMinY; double globalMaxX, globalMaxY; double gap = 500; Boolean executedOnce = false; double commonminY = 0; double commonminX = 0; double commonmaxY = 0; List <RhinoObject> imported = new List <RhinoObject>(); //holds the imported rhino obects (all objects) List <RhinoObject> oldObjs = new List <RhinoObject>(); //holds the old objects in the document List <RhinoObject> newObjs = new List <RhinoObject>(); //holds the new objects in the document Boolean newObjFound = false; if (dr == System.Windows.Forms.DialogResult.OK) { //Select direction and angle double rotationAngle = 0; bool anticlockwise = true; MessageBoxButtons buttons = MessageBoxButtons.YesNo; DialogResult result = MessageBox.Show("Do you want to rotate each dxf imported by 90°?", "DXF rotation", buttons); if (result == DialogResult.Yes) { rotationAngle = 90; result = MessageBox.Show("Select the rotation direction: 'Yes' for 'Anti-clockwise' and 'No' for 'Clockwise'.", "Rotation Direction", buttons); if (result == DialogResult.No) { rotationAngle = -90; anticlockwise = false; } } // Read the files foreach (String file in openFileDialog.FileNames) { importMinX = Double.MaxValue; importMinY = Double.MaxValue; importMaxX = Double.MinValue; importMaxY = Double.MinValue; globalMinX = Double.MaxValue; globalMinY = Double.MaxValue; globalMaxX = Double.MinValue; globalMaxY = Double.MinValue; // Import each file try { sScript = String.Format("! _-Import \"{0}\" _Enter", file); firstSN = RhinoObject.NextRuntimeSerialNumber; RhinoApp.RunScript(sScript, false); lastSN = RhinoObject.NextRuntimeSerialNumber; //Investigate later List <Guid> ids = new List <Guid>(); imported = new List <RhinoObject>(); newObjs = new List <RhinoObject>(); foreach (RhinoObject obj in doc.Objects) { if (obj.RuntimeSerialNumber >= firstSN && obj.RuntimeSerialNumber < lastSN) { imported.Add(obj); ids.Add(obj.Id); bbox = obj.Geometry.GetBoundingBox(Plane.WorldXY); if (importMaxX < bbox.Max.X) { importMaxX = bbox.Max.X; } if (importMaxY < bbox.Max.Y) { importMaxY = bbox.Max.Y; } if (importMinX > bbox.Min.X) { importMinX = bbox.Min.X; } if (importMinY > bbox.Min.Y) { importMinY = bbox.Min.Y; } } else { //Global bbox = obj.Geometry.GetBoundingBox(Plane.WorldXY); if (globalMaxX < bbox.Max.X) { globalMaxX = bbox.Max.X; } if (globalMaxY < bbox.Max.Y) { globalMaxY = bbox.Max.Y; } if (globalMinX > bbox.Min.X) { globalMinX = bbox.Min.X; } if (globalMinY > bbox.Min.Y) { globalMinY = bbox.Min.Y; } } } if (!executedOnce) //execute this only once { commonminY = importMinY; commonminX = importMinX; commonmaxY = importMaxY; } var startPoint = new Point3d(importMinX, importMinY, 0); if (globalMaxX == Double.MinValue) { globalMaxX = 0; } if (globalMaxY == Double.MinValue) { globalMaxY = 0; } if (globalMinX == Double.MaxValue) { globalMinX = 0; } if (globalMinY == Double.MaxValue) { globalMinY = 0; } var endPoint = new Point3d(globalMaxX + gap, commonminY, 0); List <string> names = new List <string>(); //find which type of perimeter for (int i = 0; i < 100; i++) { if (doc.Layers.FindIndex(i) != null) { names.Add(doc.Layers.FindIndex(i).Name); } else { break; } } /* * String perimeterName = "Default"; * //Get the correct perimeter name * if (doc.Layers.Find("LAYERS_FOR_NESTING$PANEL_P", true) >= 0) * { * perimeterName = "LAYERS_FOR_NESTING$PANEL_P"; * } * * if (doc.Layers.Find("Panel_Perimeter", true) >= 0) * { * perimeterName = "Panel_Perimeter"; * } */ int layer_index = doc.Layers.Find("PANEL PERIMETER", true); if (layer_index < 0) { // Add a new layer to the document layer_index = doc.Layers.Add("PANEL PERIMETER", System.Drawing.Color.Black); } foreach (string perimeterName in names) { foreach (RhinoObject obj in doc.Objects.FindByLayer(perimeterName)) { ObjRef objR = new ObjRef(obj); if (objR.Curve() == null) { continue; } //loop through the old objects array to find if the object is found in the array foreach (RhinoObject rhinObj in oldObjs) { if (rhinObj.Id.Equals(obj.Id)) //if the ids are equals it means the object belongs to a panel which has already been rotated { newObjFound = true; //set to true break; //exit from this second loop } } if (!newObjFound) //go in only if the newObjectfound is false { newObjs.Add(obj); //add the new object to the array } newObjFound = false; //set the variable back to false } } // Move all the objects var xform = Transform.Translation(endPoint - startPoint); foreach (var objRef in imported) { doc.Objects.Transform(objRef, xform, true); } executedOnce = true; Rhino.Geometry.Point3d pt = new Rhino.Geometry.Point3d(globalMaxX + gap, (commonminY + commonmaxY) / 2, 0); Rhino.Geometry.Plane plane = doc.Views.ActiveView.ActiveViewport.ConstructionPlane(); plane.Origin = pt; String dimension = findLeastDimension(newObjs, plane, "PANEL PERIMETER", rotationAngle); //call the method and pass the parameters to find the min X and min Y for the panel // Add the file as the label //The codes below are to create red labels for each panel double height = (importMaxY - importMinY) * 0.1; //double height = 3; string label = Path.GetFileNameWithoutExtension(file); int layerIndex = doc.Layers.CurrentLayerIndex; RhinoUtilities.SetActiveLayer("LABELS", System.Drawing.Color.Red); const string font = "Arial"; plane = doc.Views.ActiveView.ActiveViewport.ConstructionPlane(); plane.Origin = pt; Guid labelGuid = doc.Objects.AddText(label, plane, height, font, false, false); ids.Add(labelGuid); imported.Add(doc.Objects.Find(labelGuid)); doc.Layers.SetCurrentLayerIndex(layerIndex, true); //panelDetails = panelDetails + label + "\t" + (importMaxX - importMinX) + "\t" + (importMaxY - importMinY) + "\n"; panelDetails = panelDetails + label + "#" + dimension + "\n"; //set the dimension with the panel name vv //int index = doc.Groups.Add(ids); oldObjs.AddRange(newObjs); } catch (Exception ex) { // Could not load the image - probably related to Windows file system permissions. MessageBox.Show(ex.Message); } } double labelHeight = 100; Rhino.Geometry.Point3d panelDetailsPt = new Rhino.Geometry.Point3d(0, 0 + labelHeight, 0); const string labelFont = "Arial"; Rhino.Geometry.Plane panelDetailsPlane = doc.Views.ActiveView.ActiveViewport.ConstructionPlane(); panelDetailsPlane.Origin = panelDetailsPt; doc.Objects.AddText(panelDetails, panelDetailsPlane, labelHeight, labelFont, false, false); doc.Layers.Delete(doc.Layers.Find("temp", false), true); exportToExcel(panelDetails); //call to export panel dimensions to excel } Messages.excelOperationComplete(); // Export the whole lot //string command = string.Format("-_Export \"" + Path.GetDirectoryName(doc.Path) + @"\" + labelName + "\" Scheme \"R12 Lines & Arcs\" Enter"); // Export the selected curves //RhinoApp.RunScript(command, true); doc.Views.Redraw(); return(Result.Success); }
protected override void OnStart(string[] args) { try { if (!EventLog.SourceExists(eventLog.Source)) { EventLog.CreateEventSource(eventLog.Source, eventLog.Log); } Log.Handler += LogHandler; } #region Sanity checks catch (SecurityException ex) { Log.Error(ex); } catch (InvalidOperationException ex) { Log.Error(ex); } #endregion if (Locations.IsPortable) { Log.Error(Resources.NoPortableMode); ExitCode = IncorrectFunction; Stop(); return; } try { _serverChannel = new IpcServerChannel( new Hashtable { { "name", IpcImplementationStore.IpcPortName }, { "portName", IpcImplementationStore.IpcPortName }, { "secure", true }, { "impersonate", true } // Use identity of client in server threads }, new BinaryServerFormatterSinkProvider { TypeFilterLevel = TypeFilterLevel.Full } // Allow deserialization of custom types #if !__MonoCS__ , IpcImplementationStore.IpcAcl #endif ); _clientChannel = new IpcClientChannel( new Hashtable { { "name", IpcImplementationStore.IpcPortName + ".Callback" } }, new BinaryClientFormatterSinkProvider()); ChannelServices.RegisterChannel(_serverChannel, ensureSecurity: false); ChannelServices.RegisterChannel(_clientChannel, ensureSecurity: false); _store = CreateStore(); _objRef = RemotingServices.Marshal(_store, IpcImplementationStore.IpcObjectUri, typeof(IImplementationStore)); // Prevent the service from expiring on Windows 10 var lease = (ILease)RemotingServices.GetLifetimeService(_store); lease.Renew(TimeSpan.FromDays(365)); } #region Error handling catch (IOException ex) { Log.Error("Failed to open cache directory:" + Environment.NewLine + ex); ExitCode = UnableToWriteToDevice; Stop(); } catch (UnauthorizedAccessException ex) { Log.Error("Failed to open cache directory:" + Environment.NewLine + ex); ExitCode = AccessDenied; Stop(); } catch (RemotingException ex) { Log.Error("Failed to open IPC connection:" + Environment.NewLine + ex); ExitCode = InvalidHandle; Stop(); } catch (SecurityException ex) { Log.Error("Failed to open IPC connection:" + Environment.NewLine + ex); ExitCode = InvalidHandle; Stop(); } #endregion }
public String findLeastDimension(List <RhinoObject> newObjs, Plane plane, String perimeterName, double rotationAngle) { RhinoDoc doc = RhinoDoc.ActiveDoc; double minX = 0; double minY = 0; double minArea = double.MaxValue; Layer layerIndex = doc.Layers.FindName("Default"); RhinoUtilities.SetActiveLayer("temp", System.Drawing.Color.Black); //Copy Objects of current layer to temp layer foreach (var selected_object in newObjs) { selected_object.Attributes.LayerIndex = doc.Layers.Find("temp", false); selected_object.CommitChanges(); } //select objects in the temporart layer and join RhinoApp.RunScript("SelNone", true); RhinoApp.RunScript("SelLayerNumber " + doc.Layers.Find("temp", true), false); //MetrixUtilities.joinCurves(doc.Layers.Find("temp", false)); //plane.Rotate(i, plane.XAxis); //rotateshape with the value of i RhinoObject[] objs = doc.Objects.FindByLayer("temp"); List <Curve> curveList = new List <Curve>(); Curve[] curveArray = null; RhinoObject obj = objs[0]; foreach (RhinoObject objt in objs) { curveList.Add(new ObjRef(objt).Curve()); } curveArray = Curve.JoinCurves(curveList); obj.Attributes.ToString(); ObjRef objR = new ObjRef(obj); Curve curve = objR.Curve(); double curvelength = -1; Curve baseline = null; double angle = 0; foreach (Curve cv in curveList) { if (cv.GetLength() > curvelength) { curvelength = cv.GetLength(); baseline = cv; angle = Math.Atan(baseline.TangentAtStart.Y / baseline.TangentAtStart.X); } } if (curveArray != null) { double maxArea = Double.MinValue; foreach (Curve tempCurve in curveArray) { BoundingBox tempBBox = tempCurve.GetBoundingBox(true); if (tempBBox.Area > maxArea) { curve = tempCurve; } } } BoundingBox boundingBox = curve.GetBoundingBox(Plane.WorldXY); List <Point3d> points = new List <Point3d>(); PolylineCurve polyline_curve = curve as PolylineCurve; double diagnal = 0; bool rectangle = false; Point3d centerC = boundingBox.Center; minArea = boundingBox.Area; minX = boundingBox.Max.X - boundingBox.Min.X; minY = boundingBox.Max.Y - boundingBox.Min.Y; /* * if (polyline_curve != null && polyline_curve.PointCount == 5) * { * for (int j = 0; j < polyline_curve.PointCount; j++) * { * points.Add(polyline_curve.Point(j)); * } * * if(Math.Round(points[0].DistanceTo(points[1])) == Math.Round(points[2].DistanceTo(points[3]))) * { * minX = points[0].DistanceTo(points[1]); * minY = points[1].DistanceTo(points[2]); * rectangle = true; * } * else * { * rectangle = false; * } * }*/ if (rectangle == false) { curve.Rotate(-angle, Plane.WorldXY.ZAxis, baseline.PointAtStart); boundingBox = curve.GetBoundingBox(Plane.WorldXY); if (boundingBox.Area < minArea) { Point3d min = boundingBox.Min; Point3d max = boundingBox.Max; minX = max.X - min.X; minY = max.Y - min.Y; } } RhinoApp.RunScript("-_Rotate " + centerC + " " + rotationAngle, false); //RhinoApp.RunScript("-_Rotate " + boundingBox.Center +" " + 5, false); //Set back the previous default layer RhinoUtilities.SetActiveLayer(perimeterName, System.Drawing.Color.Black); //Copy all object of temp layer back to the previous layer foreach (var selected_object in doc.Objects.FindByLayer("temp")) { selected_object.Attributes.LayerIndex = doc.Layers.FindByFullPath(perimeterName, false); selected_object.CommitChanges(); } doc.Layers.SetCurrentLayerIndex(doc.Layers.FindByFullPath(layerIndex.Name, false), true); //needs to fix the tab issue return(String.Format("{0}#{1}", Math.Max(minX, minY), Math.Min(minX, minY))); //return the minX and minY for the panel }
public SmuggledObjRef(ObjRef objRef) { this._objRef = objRef; }
public bool Show(ObjRef objref, bool ignoreLayerMode) { throw new NotImplementedException(); }
public void MarshaledObject(object obj, ObjRef or) { IPAddress ipAddress = (IPAddress)CallContext.GetData("ClientIP"); int x = 1; }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { GetObject go = new GetObject(); go.SetCommandPrompt("Select curve to split"); go.GeometryFilter = ObjectType.Curve; go.GeometryAttributeFilter = GeometryAttributeFilter.OpenCurve; go.SubObjectSelect = false; go.Get(); if (go.CommandResult() != Result.Success) { return(go.CommandResult()); } ObjRef object_ref = go.Object(0); RhinoObject rh_object = object_ref.Object(); Curve curve = object_ref.Curve(); if (null == rh_object || null == curve) { return(Result.Failure); } GetPoint gp = new GetPoint(); gp.SetCommandPrompt("Point on curve to split at"); gp.Constrain(curve, false); gp.Get(); if (gp.CommandResult() != Result.Success) { return(gp.CommandResult()); } Point3d point = gp.Point(); double t = Rhino.RhinoMath.UnsetValue; if (!curve.ClosestPoint(point, out t)) { return(Result.Failure); } List <double> curve_t = new List <double>(3); curve_t.Add(curve.Domain.Min); curve_t.Add(curve.Domain.Max); curve_t.Add(t); curve_t.Sort(); List <double> culled_t = curve_t.Distinct().ToList(); if (culled_t.Count < 3) { return(Result.Nothing); } ObjectAttributes attributes = rh_object.Attributes.Duplicate(); attributes.ObjectId = Guid.Empty; for (int i = 0; i < culled_t.Count - 1; i++) { Interval domain = new Interval(culled_t[i], culled_t[i + 1]); if (curve.Domain.IncludesInterval(domain)) { Curve trim = curve.Trim(domain); if (null != trim) { doc.Objects.Add(trim, attributes); } } } doc.Objects.Delete(object_ref, false); doc.Views.Redraw(); return(Result.Success); }
public static NErrorCode EntityEvaled(ObjRef exprPtr, ref ObjRef res) => ExceptionEncode(ref res, exprPtr, exprPtr => exprPtr.AsEntity.Evaled );
protected override void onReleaseOculusGrip(ref VREvent_t vrEvent) { currentState = State.READY; movePlaneRef = null; }
[System.Security.SecurityCritical] // auto-generated internal static object GetObjectData(object serObj, out string typeName, out string assemName, out string[] fieldNames, out object[] fieldValues) { Type objectType = null; object retObj = null; if (RemotingServices.IsTransparentProxy(serObj)) { objectType = typeof(MarshalByRefObject); } else { objectType = serObj.GetType(); } SerializationInfo si = new SerializationInfo(objectType, s_converter); if (serObj is ObjRef) { s_ObjRefRemotingSurrogate.GetObjectData(serObj, si, s_cloneContext); } else if (RemotingServices.IsTransparentProxy(serObj) || serObj is MarshalByRefObject) { // We can only try to smuggle objref's for actual CLR objects // or for RemotingProxy's. if (!RemotingServices.IsTransparentProxy(serObj) || RemotingServices.GetRealProxy(serObj) is RemotingProxy) { ObjRef objRef = RemotingServices.MarshalInternal((MarshalByRefObject)serObj, null, null); if (objRef.CanSmuggle()) { if (RemotingServices.IsTransparentProxy(serObj)) { RealProxy rp = RemotingServices.GetRealProxy(serObj); objRef.SetServerIdentity(rp._srvIdentity); objRef.SetDomainID(rp._domainID); } else { ServerIdentity srvId = (ServerIdentity)MarshalByRefObject.GetIdentity((MarshalByRefObject)serObj); srvId.SetHandle(); objRef.SetServerIdentity(srvId.GetHandle()); objRef.SetDomainID(AppDomain.CurrentDomain.GetId()); } objRef.SetMarshaledObject(); retObj = objRef; } } if (retObj == null) { // Deal with the non-smugglable remoting objects s_RemotingSurrogate.GetObjectData(serObj, si, s_cloneContext); } } else if (serObj is ISerializable) { ((ISerializable)serObj).GetObjectData(si, s_cloneContext); } else { // Getting here means a throw new ArgumentException(Environment.GetResourceString("Arg_SerializationException")); } if (retObj == null) { typeName = si.FullTypeName; assemName = si.AssemblyName; fieldNames = si.MemberNames; fieldValues = si.MemberValues; } else { typeName = null; assemName = null; fieldNames = null; fieldValues = null; } return(retObj); }
private void computeContourCurve() { if (targetPRhObjID == Guid.Empty) { return; } ObjRef targetpObjRef = new ObjRef(targetPRhObjID); snapPointsList = new List <Point3d>(); Double tolerance = 0; if (drawnType != DrawnType.In3D) { Brep targetBrep = (Brep)(targetpObjRef.Object().Geometry); //TODO- topLeftP won't be on the face in the 3D case. so probably use orgin float minD = 1000000f; int minIndex = -1; for (int i = 0; i < targetBrep.Faces.Count; i++) { //cast BrepFace to Brep for ClosestPoint(P) menthod double dist = targetBrep.Faces[i].DuplicateFace(false).ClosestPoint(projectP).DistanceTo(projectP); if (dist < minD) { minD = (float)dist; minIndex = i; } } Surface s = targetBrep.Faces[minIndex]; //surface might not be a perfect planar surface while (tolerance < toleranceMax) { if (s.TryGetPlane(out curvePlane, tolerance)) { break; } tolerance++; } if (tolerance >= toleranceMax) { double u, v; if (s.ClosestPoint(projectP, out u, out v)) { Rhino.Geometry.Vector3d normal = s.NormalAt(u, v); //TODO fix the issue when normal is inward curvePlane = new Plane(projectP, normal); } } else { //testing finding the edge curve Rhino.Geometry.Curve[] edgeCurves = (targetBrep.Faces[minIndex].DuplicateFace(false)).DuplicateEdgeCurves(true); double tol = mScene.rhinoDoc.ModelAbsoluteTolerance * 2.1; edgeCurves = Rhino.Geometry.Curve.JoinCurves(edgeCurves, tol); // TODO: Check if null contourCurve = edgeCurves[0]; //detect whether it's rect or circle then generate a snap pointList Circle circle; Rhino.Geometry.Polyline polyline; if (contourCurve.TryGetCircle(out circle)) { snapPointsList.Add(circle.Center); snapPointsList.Add(circle.PointAt(0)); snapPointsList.Add(circle.PointAt(Math.PI / 2)); snapPointsList.Add(circle.PointAt(Math.PI)); snapPointsList.Add(circle.PointAt(Math.PI * 1.5)); } else if (contourCurve.TryGetPolyline(out polyline)) { Rectangle3d rect = Rectangle3d.CreateFromPolyline(polyline); snapPointsList.Add(rect.Center); snapPointsList.Add(rect.Corner(0)); snapPointsList.Add(rect.Corner(1)); snapPointsList.Add(rect.Corner(2)); snapPointsList.Add(rect.Corner(3)); } else { double u = 0; double v = 0; s.ClosestPoint(s.GetBoundingBox(true).Center, out u, out v); snapPointsList.Add(s.PointAt(u, v)); } } } }
public void UnmarshaledObject(Object obj, ObjRef objRef) { Console.WriteLine("Tracking: An instance of {0} was unmarshaled.", obj.ToString()); }
private string SerializeDebuggerOptions(string jsonDebugOptions) { try { NLogService.TraceEnteringMethod(Logger); var debugOptions = DebugOptions.DeserializeFromJson(jsonDebugOptions); _session = new SoftDebuggerSession(); LogMonoDebuggerAssemblyPaths(); if (debugOptions.UserSettings.EnableVerboseDebugLogging) { Debug.WriteLine("TargetReady!"); CreateAndRegisterXamarinThread(eventArgs.Thread); } ; _session.ExceptionHandler = exception => true; _session.TargetExited += (sender, x) => { Debug.WriteLine("TargetExited!"); }; _session.TargetUnhandledException += (sender, x) => { Debug.WriteLine("TargetUnhandledException!"); }; _session.LogWriter = (stderr, text) => Debug.WriteLine(text); _session.OutputWriter = (stderr, text) => Debug.WriteLine(text); _session.TargetThreadStarted += (sender, x) => { Debug.WriteLine("TargetThreadStarted!"); CreateAndRegisterXamarinThread(x.Thread); }; _session.TargetThreadStopped += (sender, x) => { Debug.WriteLine("TargetThreadStopped!"); }; _session.TargetStopped += (sender, x) => { Debug.WriteLine(x.Type); }; _session.TargetStarted += (sender, x) => Debug.WriteLine("TargetStarted"); _session.TargetSignaled += (sender, x) => Debug.WriteLine(x.Type); _session.TargetInterrupted += (sender, x) => { Debug.WriteLine(x.Type); }; _session.TargetExceptionThrown += (sender, x) => { Debug.WriteLine("TargetExceptionThrown!"); }; _session.TargetHitBreakpoint += (sender, x) => { Debug.WriteLine("TargetHitBreakpoint!"); }; _session.TargetEvent += _session_TargetEvent; var connectionTimeout = 30000; var evaluationTimeout = 30000; var startupProject = StartupProject; var softDebuggerConnectArgs = new SoftDebuggerConnectArgs(debugOptions.TargetExeFileName, debugOptions.GetHostIP(), debugOptions.GetMonoDebugPort()); // TODO implement programm output via stream //softDebuggerConnectArgs.RedirectOutput = true; //softDebuggerConnectArgs.OutputPort = ???; //_session.VirtualMachine.StandardOutput ??? softDebuggerConnectArgs.TimeBetweenConnectionAttempts = (int)debugOptions.UserSettings.TimeBetweenConnectionAttemptsInMs; softDebuggerConnectArgs.MaxConnectionAttempts = (int)debugOptions.UserSettings.MaxConnectionAttempts; _startInfo = new StartInfo( softDebuggerConnectArgs, new DebuggingOptions() { EvaluationTimeout = evaluationTimeout, MemberEvaluationTimeout = evaluationTimeout, ModificationTimeout = evaluationTimeout, SocketTimeout = connectionTimeout }, startupProject ); SessionMarshalling sessionMarshalling = new SessionMarshalling(_session, _startInfo); using (MemoryStream ms = new MemoryStream()) { BinaryFormatter bf = new BinaryFormatter(); ObjRef oref = RemotingServices.Marshal(sessionMarshalling); bf.Serialize(ms, oref); return(Convert.ToBase64String(ms.ToArray())); } } catch (Exception ex) { Logger.Error(ex); throw; } }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { const ObjectType geometryFilter = ObjectType.Curve; GetObject get_rail = new GetObject(); get_rail.SetCommandPrompt("Select rail curve"); get_rail.GeometryFilter = geometryFilter; //get_rail.GeometryAttributeFilter = GeometryAttributeFilter.OpenCurve; get_rail.SubObjectSelect = false; get_rail.Get(); if (get_rail.CommandResult() != Result.Success) { return(get_rail.CommandResult()); } ObjRef rail_objref = get_rail.Object(0); Curve rail_curve = rail_objref.Curve(); if (null == rail_curve) { return(Result.Failure); } GetObject get_shape = new GetObject(); get_shape.SetCommandPrompt("Select cross section curve"); get_shape.GeometryFilter = geometryFilter; //get_shape.GeometryAttributeFilter = GeometryAttributeFilter.OpenCurve; get_shape.SubObjectSelect = false; get_shape.EnablePreSelect(false, false); get_shape.DeselectAllBeforePostSelect = false; get_shape.Get(); if (get_shape.CommandResult() != Result.Success) { return(get_shape.CommandResult()); } ObjRef shape_objref = get_shape.Object(0); Curve shape_curve = shape_objref.Curve(); if (null == shape_curve) { return(Result.Failure); } double tolerance = doc.ModelAbsoluteTolerance; Brep[] brep = Brep.CreateFromSweep(rail_curve, shape_curve, false, tolerance); if (null == brep || 0 == brep.Length) { return(Result.Failure); } // Create a history record HistoryRecord history = new HistoryRecord(this, HISTORY_VERSION); WriteHistory(history, rail_objref, shape_objref, tolerance); for (int i = 0; i < brep.Length; i++) { doc.Objects.AddBrep(brep[i], null, history, false); } doc.Views.Redraw(); return(Result.Success); }
public void UnmarshaledObject(object obj, ObjRef objRef) { }
/// <summary> /// 将指定的对象设置为远程共享对象 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="sharedObject"></param> /// <param name="ObjURI"></param> /// <returns></returns> public static ObjRef SetRemoteSharedObject <T>(T sharedObject, string ObjURI) where T : MarshalByRefObject { ObjRef objRef = RemotingServices.Marshal(sharedObject, ObjURI, typeof(T)); return(objRef); }
[System.Security.SecurityCritical] // auto-generated internal static void MarshaledObject(Object obj, ObjRef or) { try{ ITrackingHandler[] temp = _Handlers; for(int i = 0; i < _Size; i++) { Volatile.Read(ref temp[i]).MarshaledObject(obj, or); } } catch {} }
/// <summary> /// 推送广播远程到通道 /// </summary> private static void ConnectBroadCastObj() { string broadCastObjURI = ConfigurationManager.AppSettings["BroadCastObjURI"]; ObjRef objRef = RemotingServices.Marshal(Obj, broadCastObjURI); }
public static NErrorCode Differentiate(ObjRef exprPtr, ObjRef varPtr, ref ObjRef res) => ExceptionEncode(ref res, (exprPtr, varPtr), static e =>
public static object Unmarshal(ObjRef objectRef, bool fRefine) { }
public static NErrorCode EntityVarsAndConstants(ObjRef exprPtr, ref NativeArray res) => ExceptionEncode(ref res, exprPtr, exprPtr => NativeArray.Alloc(exprPtr.AsEntity.VarsAndConsts.Select(v => (Entity)v)) );
internal static object GetObjectData(object serObj, out string typeName, out string assemName, out string[] fieldNames, out object[] fieldValues) { object obj = null; Type type; if (RemotingServices.IsTransparentProxy(serObj)) { type = typeof(MarshalByRefObject); } else { type = serObj.GetType(); } SerializationInfo serializationInfo = new SerializationInfo(type, ObjectCloneHelper.s_converter); if (serObj is ObjRef) { ObjectCloneHelper.s_ObjRefRemotingSurrogate.GetObjectData(serObj, serializationInfo, ObjectCloneHelper.s_cloneContext); } else if (RemotingServices.IsTransparentProxy(serObj) || serObj is MarshalByRefObject) { if (!RemotingServices.IsTransparentProxy(serObj) || RemotingServices.GetRealProxy(serObj) is RemotingProxy) { ObjRef objRef = RemotingServices.MarshalInternal((MarshalByRefObject)serObj, null, null); if (objRef.CanSmuggle()) { if (RemotingServices.IsTransparentProxy(serObj)) { RealProxy realProxy = RemotingServices.GetRealProxy(serObj); objRef.SetServerIdentity(realProxy._srvIdentity); objRef.SetDomainID(realProxy._domainID); } else { ServerIdentity serverIdentity = (ServerIdentity)MarshalByRefObject.GetIdentity((MarshalByRefObject)serObj); serverIdentity.SetHandle(); objRef.SetServerIdentity(serverIdentity.GetHandle()); objRef.SetDomainID(AppDomain.CurrentDomain.GetId()); } objRef.SetMarshaledObject(); obj = objRef; } } if (obj == null) { ObjectCloneHelper.s_RemotingSurrogate.GetObjectData(serObj, serializationInfo, ObjectCloneHelper.s_cloneContext); } } else { if (!(serObj is ISerializable)) { throw new ArgumentException(Environment.GetResourceString("Arg_SerializationException")); } ((ISerializable)serObj).GetObjectData(serializationInfo, ObjectCloneHelper.s_cloneContext); } if (obj == null) { typeName = serializationInfo.FullTypeName; assemName = serializationInfo.AssemblyName; fieldNames = serializationInfo.MemberNames; fieldValues = serializationInfo.MemberValues; } else { typeName = null; assemName = null; fieldNames = null; fieldValues = null; } return(obj); }
public void UnmarshaledObject(object obj, ObjRef or) { Console.WriteLine("Unmarshal"); }
[System.Security.SecurityCritical] // auto-generated internal static void UnmarshaledObject(Object obj, ObjRef or) { try{ ITrackingHandler[] temp = _Handlers; for(int i = 0; i < _Size; i++) { temp[i].UnmarshaledObject(obj, or); } } catch {} }
public static NErrorCode EntityNodes(ObjRef exprPtr, ref NativeArray res) => ExceptionEncode(ref res, exprPtr, exprPtr => NativeArray.Alloc(exprPtr.AsEntity.Nodes) );