コード例 #1
0
        public override void Load()
        {
            Hotkeys.Load();
            Core.Load();
            FastForwardBoost.Load();
            DisableAchievements.Load();
            GraphicsCore.Load();
            SimplifiedGraphicsFeature.Load();
            CenterCamera.Load();
            AutoMute.Load();
            HideGameplay.Load();
            HitboxTweak.Load();
            InfoHud.Load();
            ConsoleEnhancements.Load();

            AttributeUtils.Invoke <LoadAttribute>();

            // Open unix IO pipe for interfacing with Linux / Mac Celeste Studio
            if (UnixRtcEnabled)
            {
                File.Delete("/tmp/celestetas");
                UnixRtc = new NamedPipeServerStream("/tmp/celestetas", PipeDirection.InOut);
                UnixRtc.WaitForConnection();
                UnixRtcStreamOut = new StreamWriter(UnixRtc);
                UnixRtcStreamIn  = new StreamReader(UnixRtc);
                Logger.Log("CelesteTAS", "Unix socket is active on /tmp/celestetas");
            }

            // Open memory mapped file for interfacing with Windows Celeste Studio
            StudioCommunicationClient.Run();

#if DEBUG
            Benchmark.Load();
#endif
        }
コード例 #2
0
ファイル: JsmlSerializer.cs プロジェクト: hksonngan/Xian
 protected OptionsBase()
 {
     // default filters
     this.DataContractTest = m => AttributeUtils.HasAttribute <DataContractAttribute>(m, false);
     this.DataMemberTest   = m => AttributeUtils.HasAttribute <DataMemberAttribute>(m, true);
     this.Hook             = new NullHook();
 }
コード例 #3
0
        private void InitPrivate(int tag, DataFormat dataFormat, bool isOptional, MemberInfo member, Delegate getValue, Delegate setValue, object defaultValue)
        {
            if (this.prefix != 0)
            {
                throw new InvalidOperationException("Can only initialise a property once");
            }

            if (member != null)
            {
                MemberSerializationOptions options;
                if (!Serializer.TryGetTag(member, out tag, out name, out dataFormat, out options))
                {
                    throw new ArgumentException(member.Name + " cannot be used for serialization", "member");
                }
                isOptional = !PropertyFactory.HasOption(options, MemberSerializationOptions.Required);
                {
                    DefaultValueAttribute dva = AttributeUtils.GetAttribute <DefaultValueAttribute>(member);
                    defaultValue = dva == null ? null : dva.Value;
                }
#if CF
                this.description = null; // not used in CF; assigned to get rid of warning
#else
                {
                    DescriptionAttribute da = AttributeUtils.GetAttribute <DescriptionAttribute>(member);
                    this.description = da == null ? null : da.Description;
                }
#endif
            }
            this.isOptional   = isOptional;
            this.defaultValue = defaultValue;
            this.dataFormat   = dataFormat; // set initial format, and use the *field* for the "ref" so either usage is valid
            OnBeforeInit(member, getValue, setValue, tag, ref this.dataFormat);
            this.prefix = Serializer.GetFieldToken(tag, WireType);
            OnAfterInit();
        }
コード例 #4
0
        private void BuildTestsFromMethod(Test parent, IMethodInfo method, string namePrefix, string nameSuffix)
        {
            try
            {
                foreach (TestAttribute2 attrib in AttributeUtils.GetAttributes <TestAttribute2>(method, true))
                {
                    BuildTest(parent, method, namePrefix, nameSuffix, attrib);
                }

                foreach (RowTestAttribute2 attrib in AttributeUtils.GetAttributes <RowTestAttribute2>(method, true))
                {
                    BuildRowTest(parent, method, namePrefix, nameSuffix, attrib);
                }

                foreach (CombinatorialTestAttribute2 attrib in AttributeUtils.GetAttributes <CombinatorialTestAttribute2>(method, true))
                {
                    BuildCombinatorialTest(parent, method, namePrefix, nameSuffix, attrib);
                }
            }
            catch (Exception ex)
            {
                testModel.AddAnnotation(new Annotation(AnnotationType.Error, method,
                                                       "An exception was thrown while exploring an MbUnit v2 test method.", ex));
            }
        }
コード例 #5
0
        /// <summary>
        /// Returns the set of authority tokens defined by all plugins.
        /// </summary>
        /// <returns></returns>
        public static AuthorityTokenDefinition[] GetAuthorityTokens()
        {
            List <AuthorityTokenDefinition> tokens = new List <AuthorityTokenDefinition>();

            // scan all plugins for token definitions
            foreach (PluginInfo plugin in Platform.PluginManager.Plugins)
            {
                IResourceResolver resolver = new ResourceResolver(plugin.Assembly);
                foreach (Type type in plugin.Assembly.GetTypes())
                {
                    // look at public fields
                    foreach (FieldInfo field in type.GetFields())
                    {
                        AuthorityTokenAttribute attr = AttributeUtils.GetAttribute <AuthorityTokenAttribute>(field, false);
                        if (attr != null)
                        {
                            string token       = (string)field.GetValue(null);
                            string description = resolver.LocalizeString(attr.Description);

                            tokens.Add(new AuthorityTokenDefinition(token, description));
                        }
                    }
                }
            }
            return(tokens.ToArray());
        }
コード例 #6
0
        private static void PopulateMethodMetadata(ICodeElementInfo codeElement, PropertyBag metadata)
        {
            foreach (TestAttribute attr in AttributeUtils.GetAttributes <TestAttribute>(codeElement, true))
            {
                // Add timeout
                if (attr.Timeout > 0)
                {
                    TimeSpan timeout = TimeSpan.FromMilliseconds(attr.Timeout);
                    metadata.Add("Timeout", timeout.Seconds.ToString("0.000"));
                }

                // Add categories
                string categories = attr.Categories;
                if (!String.IsNullOrEmpty(categories))
                {
                    foreach (string category in categories.Split(','))
                    {
                        metadata.Add(MetadataKeys.Category, category);
                    }
                }
            }

            // Add expected exception type
            foreach (ExpectedExceptionAttribute attr in AttributeUtils.GetAttributes <ExpectedExceptionAttribute>(codeElement, true))
            {
                metadata.Add(MetadataKeys.ExpectedException, attr.ExceptionType.FullName);
            }

            PopulateCommonMetadata(codeElement, metadata);
        }
コード例 #7
0
ファイル: AuditAdvice.cs プロジェクト: ronmark1/ClearCanvas-1
            public void Intercept(IInvocation invocation)
            {
                // ensure the thread-static variable is initialized for the current thread
                if (_invocationInfo == null)
                {
                    _invocationInfo = new Stack <InvocationInfo>();
                }

                try
                {
                    var recorderContexts = AttributeUtils.GetAttributes <AuditRecorderAttribute>(invocation.MethodInvocationTarget, true)
                                           .Select(a => new RecorderContext(invocation, (IServiceOperationRecorder)Activator.CreateInstance(a.RecorderClass)))
                                           .ToList();

                    _invocationInfo.Push(new InvocationInfo(recorderContexts));

                    invocation.Proceed();

                    _invocationInfo.Peek().PostCommit();
                }
                finally
                {
                    // clear current invocation
                    _invocationInfo.Pop();
                }
            }
コード例 #8
0
        /// <summary>
        /// Promotes the exception to a fault, if the exception type has a corresponding fault contract.
        /// Otherwise returns null.
        /// </summary>
        /// <param name="e"></param>
        /// <param name="serviceInstance"></param>
        /// <param name="method"></param>
        /// <param name="fault"></param>
        /// <returns></returns>
        private static bool PromoteExceptionToFault(Exception e, object serviceInstance, MethodInfo method, out Exception fault)
        {
            fault = null;

            // get the service contract
            var serviceContractAttr = AttributeUtils.GetAttribute <ServiceImplementsContractAttribute>(serviceInstance.GetType(), false);

            // this should never happen, but if it does, there's nothing we can do
            if (serviceContractAttr == null)
            {
                return(false);
            }

            // find a fault contract for this exception type
            var faultContract = AttributeUtils.GetAttribute <FaultContractAttribute>(method, true, a => a.DetailType.Equals(e.GetType()));

            if (faultContract != null)
            {
                // from Juval Lowey
                var faultBoundedType = typeof(FaultException <>).MakeGenericType(e.GetType());
                fault = (FaultException)Activator.CreateInstance(faultBoundedType, e, new FaultReason(e.Message));
                return(true);
            }

            return(false);               // no fault contract for this exception
        }
コード例 #9
0
        /// <inheritdoc />
        public override void Consume(IPatternScope containingScope, ICodeElementInfo codeElement, bool skipChildren)
        {
            //TODO: Review: Issue 762: Shouldn't the base method be invoked here?
            //base.Consume(containingScope, codeElement, skipChildren);
            if (!IsReadableFieldOrProperty(codeElement))
            {
                ThrowUsageErrorException("This attribute may only be applied to fields and properties with getters.");
            }

            ISlotInfo slot      = (ISlotInfo)codeElement;
            ITypeInfo mixinType = slot.ValueType;

            if (!mixinType.IsClass || !AttributeUtils.HasAttribute(mixinType, typeof(MixinAttribute), true))
            {
                ThrowUsageErrorException(String.Format("The field or property value type must be a class with the [Mixin] attribute applied.  "
                                                       + "The type {0} does not appear to be a valid mixin class.", mixinType));
            }

            // TODO: Detect cycles.
            // TODO: Modify how fixture types and instances are interpreted in the mixin.

            IPatternScope mixinScope = containingScope.CreateScope(codeElement,
                                                                   containingScope.TestBuilder, null, containingScope.TestDataContextBuilder.CreateChild(), false);

            mixinScope.Consume(mixinType, skipChildren, null);
        }
コード例 #10
0
        //------------------------------------------------------------------------------
        //Callback Name: apply_cb
        //------------------------------------------------------------------------------
        public int apply_cb()
        {
            int errorCode = 0;

            try
            {
                //---- Enter your callback code here -----
                NXOpen.Assemblies.Component ct      = selection_Work.GetSelectedObjects()[0] as NXOpen.Assemblies.Component;
                InterferenceBuilder         builder = new InterferenceBuilder(ct.Prototype as Part);
                AttributeUtils.AttributeOperation("Interference", true, (ct.Prototype as Part));
                if (builder.CreateInterferenceBody())
                {
                    theUI.NXMessageBox.Show("提示", NXMessageBox.DialogType.Error, "电极无过切");
                }
                else
                {
                    theUI.NXMessageBox.Show("提示", NXMessageBox.DialogType.Error, "电极有过切");
                }
                // builder.CreateInterferenceFace();
                // SewUtils.SewFeatureUF(GetSheetBodyOFPart(workPart));
                //  DeleteObject.DeleteParms(GetSheetBodyOFPart(workPart).ToArray());
            }
            catch (Exception ex)
            {
                //---- Enter your exception handling code here -----
                errorCode = 1;
                theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
            }
            return(errorCode);
        }
コード例 #11
0
        //------------------------------------------------------------------------------
        //Callback Name: filter_cb
        //------------------------------------------------------------------------------
        public int filter_cb(NXOpen.BlockStyler.UIBlock block, NXOpen.TaggedObject selectedObject)
        {
            Model.MoldInfoModel info = builder.Model.Asm.MoldInfo;

            if (this.selePart.GetSelectedObjects().Length != 0)
            {
                Part   part = (this.selePart.GetSelectedObjects()[0] as NXOpen.Assemblies.Component).Prototype as Part;
                string name = AttributeUtils.GetAttrForString(part, "PartType");
                if (name.Equals("Workpiece", StringComparison.CurrentCultureIgnoreCase))
                {
                    return(UFConstants.UF_UI_SEL_ACCEPT);
                }
                if (selectedObject is Face)
                {
                    Face seleFace = selectedObject as Face;
                    Part selePart = (seleFace.Prototype as Face).OwningPart as Part;

                    if (selePart.Tag != part.Tag)
                    {
                        return(UFConstants.UF_UI_SEL_REJECT);
                    }
                }
            }
            return(NXOpen.UF.UFConstants.UF_UI_SEL_ACCEPT);
        }
コード例 #12
0
        /// <summary>
        /// 给齿上颜色
        /// </summary>
        private void SetHeadColour()
        {
            Matrix4 matr = new Matrix4();

            matr.Identity();
            Matrix4 inv = matr.GetInversMatrix();
            CartesianCoordinateSystem csys = BoundingBoxUtils.CreateCoordinateSystem(matr, inv);
            List <Body> bodys     = Session.GetSession().Parts.Work.Bodies.ToArray().ToList();
            var         toolhList = bodys.GroupBy(a => AttributeUtils.GetAttrForString(a, "ToolhName"));
            List <ElectrodeToolhInfo[, ]> toolhInfos = new List <ElectrodeToolhInfo[, ]>();

            try
            {
                foreach (var toolh in toolhList)
                {
                    ElectrodeToolhInfo[,] toolhInfo = pitch.GetToolhInfosForAttribute(toolh.ToList(), matr, csys);
                    toolhInfos.Add(toolhInfo);
                }
                if (toolhInfos.Count != 0)
                {
                    gapValue.SetERToolh(toolhInfos);
                }
            }
            catch (Exception ex)
            {
                ClassItem.WriteLogFile("设置颜色错误!" + ex.Message);
            }
        }
コード例 #13
0
        /// <summary>
        /// 设置属性
        /// </summary>
        public void SetAttribute(Part obj)
        {
            AttributeUtils.AttributeOperation("EleName", this.EleName, obj);
            AttributeUtils.AttributeOperation("BorrowName", this.BorrowName, obj);

            AttributeUtils.AttributeOperation("PitchX", this.PitchX, obj);
            AttributeUtils.AttributeOperation("PitchXNum", this.PitchXNum, obj);
            AttributeUtils.AttributeOperation("PitchY", this.PitchY, obj);
            AttributeUtils.AttributeOperation("PitchYNum", this.PitchYNum, obj);

            AttributeUtils.AttributeOperation("CrudeInter", this.CrudeInter, obj);
            AttributeUtils.AttributeOperation("CrudeNum", this.CrudeNum, obj);
            AttributeUtils.AttributeOperation("DuringInter", this.DuringInter, obj);
            AttributeUtils.AttributeOperation("DuringNum", this.DuringNum, obj);
            AttributeUtils.AttributeOperation("FineInter", this.FineInter, obj);
            AttributeUtils.AttributeOperation("FineNum", this.FineNum, obj);

            AttributeUtils.AttributeOperation("Material1", this.Material, obj);
            AttributeUtils.AttributeOperation("EleType", this.EleType, obj);
            AttributeUtils.AttributeOperation("Condition", this.Condition, obj);
            AttributeUtils.AttributeOperation("Extrudewith", this.Extrudewith, obj);
            AttributeUtils.AttributeOperation("CH", this.Ch, obj);

            AttributeUtils.AttributeOperation("IsPreparation", this.IsPreparation, obj);
            AttributeUtils.AttributeOperation("Remarks", this.Remarks, obj);
            AttributeUtils.AttributeOperation("Technology", this.Technology, obj);
            AttributeUtils.AttributeOperation("CamTemplate", this.CamTemplate, obj);

            AttributeUtils.AttributeOperation("EleSetValue", this.EleSetValue, obj);
            AttributeUtils.AttributeOperation("Preparation", this.Preparation, obj);
            AttributeUtils.AttributeOperation("ElePresentation", this.ElePresentation, obj);
            AttributeUtils.AttributeOperation("Area", this.Area, obj);
            AttributeUtils.AttributeOperation("EleNumber", this.EleNumber, obj);
            AttributeUtils.AttributeOperation("Positioning", this.Positioning, obj);
        }
コード例 #14
0
ファイル: AlterEleName.cs プロジェクト: ycchen10/MolexPlugIn
        //------------------------------------------------------------------------------
        //Callback Name: apply_cb
        //------------------------------------------------------------------------------
        public int apply_cb()
        {
            int errorCode = 0;

            try
            {
                //---- Enter your callback code here -----
                NXOpen.Assemblies.Component ct = this.seleComp.GetSelectedObjects()[0] as NXOpen.Assemblies.Component;
                Part   pt   = ct.Prototype as Part;
                string type = AttributeUtils.GetAttrForString(pt, "PartType");
                if (type.Equals("Electrode", StringComparison.CurrentCultureIgnoreCase))
                {
                    ElectrodeModel model = new ElectrodeModel();
                    model.GetModelForPart(pt);
                    ReplacePart.ReplaceElectrode(model, this.strEleName.Value.ToUpper());
                }
                else
                {
                    ReplacePart.Replace(pt, this.strEleName.Value.ToUpper());
                }
                bool           anyPartsModified;
                PartSaveStatus saveStatus;
                theSession.Parts.SaveAll(out anyPartsModified, out saveStatus);
            }
            catch (Exception ex)
            {
                //---- Enter your exception handling code here -----
                errorCode = 1;
                theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
            }
            return(errorCode);
        }
コード例 #15
0
        public static string GetKey(object message)
        {
            if (message == null)
            {
                return(null);
            }
            //var keyValue = AttributeUtils.GetPropertyValue<RouteKeyAttribute>(message);
            //if (keyValue == null)
            //{
            //    keyValue = AttributeUtils.GetPropertyValue<KeyAttribute>(message);
            //    //keyValue = AttributeUtils.GetPropertyValue(message, "RouteKey");
            //}
            //return keyValue != null ? keyValue.ToString() : null;

            var          type     = message.GetType();
            PropertyInfo property = null;

            if (RouteKeyCache.TryGetValue(type, out property))
            {
            }
            else
            {
                property = AttributeUtils.GetProperty <RouteKeyAttribute>(message);
                if (property == null)
                {
                    property = AttributeUtils.GetProperty <KeyAttribute>(message);
                }
                RouteKeyCache.TryAdd(type, property);
            }

            var keyValue = property?.GetValue(message);

            return(keyValue != null?keyValue.ToString() : null);
        }
コード例 #16
0
        private void SetDiceThrowLabel(ICaste caste, IRace race, string propertyName, Label label)
        {
            var casteAttributes          = caste.GetCustomAttributes(propertyName);
            var diceThrow                = AttributeUtils.GetAttribute <DiceThrowAttribute>(casteAttributes);
            var diceThrowModifier        = AttributeUtils.GetAttribute <DiceThrowModifierAttribute>(casteAttributes);
            var specialTrainingAttribute = AttributeUtils.GetAttribute <SpecialTrainingAttribute>(casteAttributes);

            label.Text = Lng.Elem(EnumUtils.GetDescription(diceThrow.DiceThrowType));
            if (diceThrowModifier != null)
            {
                label.Text += $" + {diceThrowModifier.Modifier}";
            }
            if (specialTrainingAttribute != null)
            {
                label.Text += $" + {Lng.Elem("St")}";
            }
            if (diceThrow.DiceThrowType.ToString().EndsWith("2_Times"))
            {
                label.Text += " (2x)";
            }
            var raceModifier = race.GetPropertyShortValue(propertyName);

            if (raceModifier != 0)
            {
                label.Text += raceModifier < 0 ? $" - {Math.Abs(raceModifier)}" : $" + {raceModifier}";
            }
        }
コード例 #17
0
 public override void LoadContent(bool firstLoad)
 {
     if (firstLoad)
     {
         AttributeUtils.Invoke <LoadContentAttribute>();
     }
 }
コード例 #18
0
        /// <summary>
        /// 设置连接体
        /// </summary>
        public void WaveBodys()
        {
            Part      workPart     = Session.GetSession().Parts.Work;
            UFSession theUFSession = UFSession.GetUFSession();

            if (workPart.Tag != this.PartTag.Tag)
            {
                NXOpen.Assemblies.Component ct = AssmbliesUtils.GetPartComp(workPart, this.PartTag);
                PartUtils.SetPartWork(ct);
            }
            foreach (Part part in Session.GetSession().Parts)
            {
                string type = AttributeUtils.GetAttrForString(part, "PartType");
                if (type.Equals("Workpiece"))
                {
                    Body[] bodys = part.Bodies.ToArray();
                    NXOpen.Features.Feature feat = AssmbliesUtils.WaveAssociativeBodys(bodys);
                    Body[] waveBodys             = ((NXOpen.Features.BodyFeature)feat).GetBodies();
                    foreach (Body body in waveBodys)
                    {
                        body.Layer = 2;
                        theUFSession.Layer.SetStatus(2, 2);
                    }
                    break;
                }
            }
            PartUtils.SetPartWork(null);
        }
コード例 #19
0
ファイル: Interference.cs プロジェクト: ycchen10/MolexPlugIn
        public void GetInterferenceOfArea()
        {
            Body        eleBody       = GetOccsInBods(this.eleModel.PartTag)[0];
            Body        workpieceBody = GetOccsInBods(this.workpiece)[0];
            List <Face> faces         = AnalysisUtils.SetInterferenceOutFace(eleBody, workpieceBody);
            double      minArea       = 0;

            for (int i = 0; i < (faces.Count) / 2 - 1; i++)
            {
                FaceData data1 = FaceUtils.AskFaceData(faces[i * 2]);
                FaceData data2 = FaceUtils.AskFaceData(faces[i * 2 + 1]);
                if (data1.Equals(data2))
                {
                    double area1 = FaceUtils.GetFaceArea(faces[i * 2]);
                    double area2 = FaceUtils.GetFaceArea(faces[i * 2 + 1]);
                    if (area1 > area2)
                    {
                        minArea += area2;
                    }
                    else
                    {
                        minArea += area1;
                    }
                }
            }
            AttributeUtils.AttributeOperation("Area", minArea, this.eleModel.PartTag);
        }
コード例 #20
0
 protected override void SetAttribute()
 {
     base.SetAttribute();
     EleInfo.SetAttribute(this.PartTag);
     AttributeUtils.AttributeOperation("Matrx4", Matrx4ToString(this.EleMatr), this.PartTag);
     AttributeUtils.AttributeOperation("WorkNumber", this.WorkNumber, this.PartTag);
 }
コード例 #21
0
        /// <summary>
        /// Returns the set of authority tokens defined by all plugins.
        /// </summary>
        /// <returns></returns>
        public static AuthorityTokenDefinition[] GetAuthorityTokens()
        {
            var tokens = new List <AuthorityTokenDefinition>();

            // scan all plugins for token definitions
            foreach (var plugin in Platform.PluginManager.Plugins)
            {
                var assembly = plugin.Assembly.Resolve();
                var resolver = new ResourceResolver(assembly);
                foreach (var type in plugin.Assembly.Resolve().GetTypes())
                {
                    // look at public fields
                    foreach (var field in type.GetFields())
                    {
                        var attr = AttributeUtils.GetAttribute <AuthorityTokenAttribute>(field, false);
                        if (attr != null)
                        {
                            var token            = (string)field.GetValue(null);
                            var description      = resolver.LocalizeString(attr.Description);
                            var formerIdentities = (attr.Formerly ?? "").Split(';');

                            tokens.Add(new AuthorityTokenDefinition(token, assembly.FullName, description, formerIdentities));
                        }
                    }
                }
            }
            return(tokens.ToArray());
        }
コード例 #22
0
        private static Dictionary <string, PropertyData> WriteProperties(EntityChange entityChange)
        {
            var propertiesData = new Dictionary <string, PropertyData>();

            var entityClass = EntityRefUtils.GetClass(entityChange.EntityRef);

            foreach (var prop in entityChange.PropertyChanges)
            {
                var pi = entityClass.GetProperty(prop.PropertyName);

                // special handling of extended properties collections
                // note that we need to check pi != null because it may represent a field-access "property"
                // which has no corresponding .NET property
                if (pi != null && AttributeUtils.HasAttribute <ExtendedPropertiesCollectionAttribute>(pi))
                {
                    var extendedProps = WriteExtendedProperties(prop, entityChange.ChangeType);
                    foreach (var extendedProp in extendedProps)
                    {
                        propertiesData.Add(extendedProp.Key, extendedProp.Value);
                    }
                }
                else
                {
                    var propertyData = WriteProperty(prop.OldValue, prop.NewValue, entityChange.ChangeType);
                    propertiesData.Add(prop.PropertyName, propertyData);
                }
            }
            return(propertiesData);
        }
コード例 #23
0
        private bool PartIsAsm()
        {
            Part workPart = Session.GetSession().Parts.Work;

            if (!ParentAssmblieInfo.IsAsm(workPart))
            {
                asm = ASMCollection.GetAsmModel(workPart);
                if (asm == null)
                {
                    ClassItem.MessageBox("无法通过工作部件找到ASM!", NXMessageBox.DialogType.Error);
                    return(false);
                }

                PartUtils.SetPartDisplay(asm.PartTag);
            }
            asm     = new ASMModel(workPart);
            asmColl = new ASMCollection(asm);
            foreach (WorkModel wk in asmColl.GetWorks())
            {
                bool isInter = AttributeUtils.GetAttrForBool(wk.PartTag, "Interference");
                if (!isInter)
                {
                    NXOpen.UI.GetUI().NXMessageBox.Show("提示", NXMessageBox.DialogType.Error, wk.AssembleName + "没有检查电极");
                    return(false);
                }
            }
            return(true);
        }
コード例 #24
0
        /// <summary>
        /// 修改电极名
        /// </summary>
        /// <param name="model"></param>
        /// <param name="newName"></param>
        /// <returns></returns>
        public static Part ReplaceElectrode(ElectrodeModel model, string newName)
        {
            Session   theSession  = Session.GetSession();
            Part      workPart    = theSession.Parts.Work;
            Component ct          = model.GetPartComp(workPart);
            string    OldName     = model.EleInfo.EleName;
            string    newPartPath = model.WorkpiecePath.Replace(OldName, newName);

            File.Move(model.WorkpiecePath, newPartPath);
            if (ct != null)
            {
                model.PartTag.Close(NXOpen.BasePart.CloseWholeTree.False, NXOpen.BasePart.CloseModified.UseResponses, null);
                if (Basic.AssmbliesUtils.ReplaceComp(ct, newPartPath, ct.Name.Replace(OldName, newName)))
                {
                    Part   elePart = ct.Prototype as Part;
                    string dwgPath = model.WorkpieceDirectoryPath + model.AssembleName + "_dwg.prt";
                    AttributeUtils.AttributeOperation("EleName", newName, elePart);
                    AttributeUtils.AttributeOperation("EleNumber", GetEleNumber(newName), elePart);
                    if (File.Exists(dwgPath))
                    {
                        UFSession         theUFSession = UFSession.GetUFSession();
                        Tag               partTag;
                        UFPart.LoadStatus error_status;
                        File.Move(dwgPath, dwgPath.Replace(OldName, newName));
                        theUFSession.Part.Open(dwgPath.Replace(OldName, newName), out partTag, out error_status);
                        AttributeUtils.AttributeOperation("EleName", newName, NXObjectManager.Get(partTag) as Part);
                    }
                    return(elePart);
                }
                return(null);
            }
            return(null);
        }
コード例 #25
0
        public void AddMemberConstraint(MemberInfo member, Attribute attribute)
        {
            List <Attribute> constraints;

            if (!membersAttributesDictionary.TryGetValue(member, out constraints))
            {
                constraints = new List <Attribute>();
                membersAttributesDictionary.Add(member, constraints);
            }
            Attribute found = constraints.Find(x => x.TypeId.Equals(attribute.TypeId));

            if (found == null || AttributeUtils.AttributeAllowsMultiple(attribute))
            {
#if NETFX
                log.Debug(string.Format("For class {0} Adding member {1} to dictionary with attribute {2}", EntityType.FullName,
                                        member.Name, attribute));
#else
                Log.Debug("For class {0} Adding member {1} to dictionary with attribute {2}", EntityType.FullName,
                          member.Name, attribute);
#endif
                membersAttributesDictionary[member].Add(attribute);
            }
            else
            {
#if NETFX
                log.Debug("Duplicated Attribute avoided: Class:" + typeof(T).FullName + " Member:" + member.Name + " Attribute:"
                          + attribute);
#else
                Log.Debug("Duplicated Attribute avoided: Class: {0} Member: {1} Attribute: {2}", typeof(T).FullName,
                          member.Name, attribute);
#endif
            }
        }
コード例 #26
0
        private EnumerationInfo ReadHardEnum(Type enumValueClass, Table table)
        {
            Type enumType = _mapClassToEnum[enumValueClass];

            int displayOrder = 1;

            // note that we process the enum constants in order of the underlying value assigned
            // so that the initial displayOrder reflects the natural ordering
            // (see msdn docs for Enum.GetValues for details)
            return(new EnumerationInfo(enumValueClass.FullName, table.Name, true,
                                       CollectionUtils.Map <object, EnumerationMemberInfo>(Enum.GetValues(enumType),
                                                                                           delegate(object value)
            {
                string code = Enum.GetName(enumType, value);
                FieldInfo fi = enumType.GetField(code);

                EnumValueAttribute attr = AttributeUtils.GetAttribute <EnumValueAttribute>(fi);
                return new EnumerationMemberInfo(
                    code,
                    attr != null ? attr.Value : null,
                    attr != null ? attr.Description : null,
                    displayOrder++,
                    false);
            })));
        }
コード例 #27
0
        /// <summary>
        /// Attempts to instantiate a script engine for the specified language.
        /// </summary>
        /// <remarks>
        /// <para>
        /// Internally, this class looks for an extension of <see cref="ScriptEngineExtensionPoint"/>
        /// that is capable of running scripts in the specified language.
        /// In order to be considered a match, extensions must be decorated with a
        /// <see cref="LanguageSupportAttribute"/> matching the <paramref name="language"/> parameter.
        /// </para>
        /// <para>
        /// If the engine is marked as a singleton, and a cached instance already exists, that instance will
        /// be returned.
        /// </para>
        /// <para>
        /// This method can safely be called by multiple threads.
        /// </para>
        /// </remarks>
        /// <param name="language">The case-insensitive script language, so jscript is equivalent to JScript.</param>
        public static IScriptEngine GetEngine(string language)
        {
            lock (_syncLock)
            {
                // check for a cached singleton engine instance for this language
                IScriptEngine engine;
                if (_singletonEngineInstances.TryGetValue(language, out engine))
                {
                    return(engine);
                }

                // create a new engine instance
                engine = CreateEngine(language);

                var optionsAttr = AttributeUtils.GetAttribute <ScriptEngineOptionsAttribute>(engine.GetType());
                if (optionsAttr != null)
                {
                    // if the engine requires synchronization, wrap it
                    if (optionsAttr.SynchronizeAccess)
                    {
                        engine = new SynchronizedScriptEngineWrapper(engine);
                    }

                    // if the engine is a singleton, cache this instance
                    if (optionsAttr.Singleton)
                    {
                        _singletonEngineInstances.Add(language, engine);
                    }
                }
                return(engine);
            }
        }
コード例 #28
0
        private void GatherNamespaceToRender(string nsPrefix, SortedList nsListToRender, Hashtable nsLocallyDeclared)
        {
            foreach (object a in nsListToRender.GetKeyList())
            {
                if (AttributeUtils.HasNamespacePrefix((XmlAttribute)a, nsPrefix))
                {
                    return;
                }
            }

            int          rDepth;
            XmlAttribute local      = (XmlAttribute)nsLocallyDeclared[nsPrefix];
            XmlAttribute rAncestral = GetNearestNamespaceWithMatchingPrefix(nsPrefix, out rDepth);

            if (local != null)
            {
                if (AttributeUtils.IsNonRedundantNamespaceDecl(local, rAncestral))
                {
                    nsLocallyDeclared.Remove(nsPrefix);
                    nsListToRender.Add(local, null);
                }
            }
            else
            {
                int          uDepth;
                XmlAttribute uAncestral = GetNearestNamespaceWithMatchingPrefix(nsPrefix, out uDepth, false);
                if (uAncestral != null && uDepth > rDepth && AttributeUtils.IsNonRedundantNamespaceDecl(uAncestral, rAncestral))
                {
                    nsListToRender.Add(uAncestral, null);
                }
            }
        }
コード例 #29
0
        /// <summary>
        /// 通过属性获取
        /// </summary>
        /// <param name="bodys">一种齿(阵列)</param>
        /// <returns></returns>
        public ElectrodeToolhInfo[,] GetToolhInfosForAttribute(List <Body> bodys, Matrix4 matr, CartesianCoordinateSystem csys)
        {
            ElectrodeToolhInfo[,] info = new ElectrodeToolhInfo[this.PitchXNum, this.PitchYNum];
            var toolhNumList             = bodys.GroupBy(a => AttributeUtils.GetAttrForInt(a, "ToolhNumber"));
            List <BodyPitchClassify> bps = new List <BodyPitchClassify>();

            foreach (var toolhNum in toolhNumList)
            {
                BodyPitchClassify bp = new BodyPitchClassify(toolhNum.ToList(), matr, csys, this.PitchXNum, this.PitchYNum);
                bp.SetAttribute();
                bps.Add(bp);
            }
            for (int i = 0; i < this.PitchXNum; i++)
            {
                for (int k = 0; k < this.PitchYNum; k++)
                {
                    List <Body> temp = new List <Body>();
                    foreach (BodyPitchClassify by in bps)
                    {
                        temp.Add(by.ClassifyBodys[i, k]);
                    }
                    info[i, k] = ElectrodeToolhInfo.GetToolhInfoForAttribute(temp.ToArray());
                }
            }
            return(info);
        }
コード例 #30
0
        private void GetEFanERFace(List <Face> faces, out Dictionary <double, Face[]> dic)
        {
            List <Face> erFaces = new List <Face>();
            List <Face> efFaces = new List <Face>();

            dic = new Dictionary <double, Face[]>();
            if (faces.Count > 0)
            {
                foreach (Face fe in faces)
                {
                    string er = AttributeUtils.GetAttrForString(fe, "ToolhGapValue");
                    if (er.Equals("ER", StringComparison.CurrentCultureIgnoreCase))
                    {
                        erFaces.Add(fe);
                    }
                    else if (er.Equals("EF", StringComparison.CurrentCultureIgnoreCase))
                    {
                        efFaces.Add(fe);
                    }
                }
            }
            if (!this.IsOffsetInter)
            {
                dic.Add(this.model.Info.AllInfo.GapValue.FineInter, efFaces.ToArray());
                dic.Add(this.model.Info.AllInfo.GapValue.DuringInter, erFaces.ToArray());
            }
            else
            {
                dic.Add(0, faces.ToArray());
            }
        }