public static void SetEvaluator(IEvaluatedNetworkAttribute netAttribute, INetworkSource netSource, Type t, esriNetworkEdgeDirection dirType)
        {
            object            obj  = Activator.CreateInstance(t);
            INetworkEvaluator eval = obj as INetworkEvaluator;

            netAttribute.set_Evaluator(netSource, dirType, eval);
        }
示例#2
0
        /// <summary>Creates new network attribute parameters</summary>
        private static void AddNetworkParameters(NetworkAttributeInfo nai, IEvaluatedNetworkAttribute netAttr)
        {
            // Create parameters
            if ((nai.Parameters != null) && (nai.Parameters.Count > 0))
            {
                IArray naParams = new ArrayClass();

                foreach (ParameterInfo paramInfo in nai.Parameters)
                {
                    INetworkAttributeParameter nap = new NetworkAttributeParameterClass();
                    nap.Name = paramInfo.Name;

                    if (paramInfo.DefaultValue is double)
                    {
                        nap.VarType = (int)VarEnum.VT_R8;
                    }
                    else if (paramInfo.DefaultValue is bool)
                    {
                        nap.VarType = (int)VarEnum.VT_BOOL;
                    }
                    else if (paramInfo.DefaultValue is string)
                    {
                        nap.VarType = (int)VarEnum.VT_BSTR;
                    }

                    nap.DefaultValue = paramInfo.DefaultValue;

                    naParams.Add(nap);
                }

                ((INetworkAttribute3)netAttr).Parameters = naParams;
            }
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            frmNewNetworkAttribute attribute = new frmNewNetworkAttribute();

            if (attribute.ShowDialog() == DialogResult.OK)
            {
                string[] items = new string[]
                {
                    "", "", attribute.NetworkAttribute.Name,
                    CommonHelper.GetUsageTypeDescriptor(attribute.NetworkAttribute.UsageType),
                    CommonHelper.GetNetworkUnitTypeDescriptor(attribute.NetworkAttribute.Units),
                    CommonHelper.GetDataTypeDescriptor(attribute.NetworkAttribute.DataType)
                };
                INetworkConstantEvaluator  evaluator        = new NetworkConstantEvaluatorClass();
                IEvaluatedNetworkAttribute networkAttribute = attribute.NetworkAttribute as IEvaluatedNetworkAttribute;
                evaluator.ConstantValue = 0;
                networkAttribute.set_DefaultEvaluator(esriNetworkElementType.esriNETEdge, evaluator as INetworkEvaluator);
                networkAttribute.set_DefaultEvaluator(esriNetworkElementType.esriNETJunction,
                                                      evaluator as INetworkEvaluator);
                networkAttribute.set_DefaultEvaluator(esriNetworkElementType.esriNETTurn, evaluator as INetworkEvaluator);
                ListViewItem item = new ListViewItem(items)
                {
                    Tag = attribute.NetworkAttribute
                };
                this.listView1.Items.Add(item);
                NewNetworkDatasetHelper.NewNetworkDataset.Attributes.Add(attribute.NetworkAttribute);
            }
        }
        public static void SetDefaultEvaluator(IEvaluatedNetworkAttribute netAttribute, object defaultValue, esriNetworkElementType eType)
        {
            INetworkConstantEvaluator constEvaluator = new NetworkConstantEvaluatorClass();

            constEvaluator.ConstantValue = defaultValue;
            INetworkEvaluator eval = constEvaluator as INetworkEvaluator;

            netAttribute.set_DefaultEvaluator(eType, eval);
        }
        public bool SupportsSource(INetworkSource source, IEvaluatedNetworkAttribute attribute)
        {
            // This custom evaluator supports added costs only for edges in attributes with units of Minutes
            bool isEdgeSource    = (source.ElementType == esriNetworkElementType.esriNETEdge);
            bool isCostAttribute = (attribute.UsageType == esriNetworkAttributeUsageType.esriNAUTCost);
            bool isMinutes       = (attribute.Units == esriNetworkAttributeUnits.esriNAUMinutes);

            return(isEdgeSource && isCostAttribute && isMinutes);
        }
        public static void SetEvaluators(IEvaluatedNetworkAttribute netAttribute, INetworkSource netSource, Type t)
        {
            esriNetworkElementType eType = netSource.ElementType;

            if (eType == esriNetworkElementType.esriNETEdge)
            {
                SetEvaluator(netAttribute, netSource, t, esriNetworkEdgeDirection.esriNEDAlongDigitized);
                SetEvaluator(netAttribute, netSource, t, esriNetworkEdgeDirection.esriNEDAgainstDigitized);
            }
            else
            {
                SetEvaluator(netAttribute, netSource, t, esriNetworkEdgeDirection.esriNEDNone);
            }
        }
示例#7
0
 public bool ValidateDefault(esriNetworkElementType elementType, IEvaluatedNetworkAttribute attribute, ref int errorCode, ref string errorDescription, ref string errorAppendInfo)
 {
     if (SupportsDefault(elementType, attribute))
     {
         errorCode        = 0;
         errorDescription = errorAppendInfo = string.Empty;
         return(true);
     }
     else
     {
         errorCode        = -1;
         errorDescription = errorAppendInfo = string.Empty;
         return(false);
     }
 }
        /// <summary>Creates new network attribute parameters</summary>
        private static void AddNetworkParameters(NetworkAttributeInfo nai, IEvaluatedNetworkAttribute netAttr)
        {
            // Create parameters
            if ((nai.Parameters != null) && (nai.Parameters.Count > 0))
            {
                IArray naParams = new ArrayClass();

                foreach (ParameterInfo paramInfo in nai.Parameters)
                {
                    INetworkAttributeParameter nap = new NetworkAttributeParameterClass();
                    nap.Name = paramInfo.Name;

                    if (paramInfo.DefaultValue is double)
                        nap.VarType = (int)VarEnum.VT_R8;
                    else if (paramInfo.DefaultValue is bool)
                        nap.VarType = (int)VarEnum.VT_BOOL;
                    else if (paramInfo.DefaultValue is string)
                        nap.VarType = (int)VarEnum.VT_BSTR;

                    nap.DefaultValue = paramInfo.DefaultValue;

                    naParams.Add(nap);
                }

                ((INetworkAttribute3)netAttr).Parameters = naParams;
            }
        }
		public void Initialize(INetworkDataset networkDataset, IDENetworkDataset dataElement, INetworkSource source, IEvaluatedNetworkAttribute attribute)
		{
			// Initialize is called once per session (ArcMap session, ArcCatalog session, etc.) to initialize the evaluator for an associated network dataset
			Type t = Type.GetTypeFromProgID("esriFramework.AppRef");
			try
			{
				// Activator.CreateInstance(t) is expected to error if the evaluator is created in an engine application 
				// which can�t get a reference to the AppRef singleton.  
				// This evaluator won�t work in Engine due to this design limitation.  It is, however,
				// fully functional in ArcMap.
				System.Object obj = Activator.CreateInstance(t);
				IApplication app = obj as IApplication;
				if (app != null && app is IMxApplication)
					m_mxDocument = app.Document as IMxDocument;
			}
			catch (Exception e)
			{
				m_mxDocument = null;
			}

			// Store reference to the network dataset and the network source
			m_networkDataset = networkDataset;
			m_networkSource = source;

			// Create a new Dictionary hashtable for this network source
			m_sourceHashTable = new Dictionary<int, int>();
		}
		public static void SetEvaluators(IEvaluatedNetworkAttribute netAttribute, INetworkSource netSource, Type t)
		{
			esriNetworkElementType eType = netSource.ElementType;
			if (eType == esriNetworkElementType.esriNETEdge)
			{
				SetEvaluator(netAttribute, netSource, t, esriNetworkEdgeDirection.esriNEDAlongDigitized);
				SetEvaluator(netAttribute, netSource, t, esriNetworkEdgeDirection.esriNEDAgainstDigitized);
			}
			else
			{
				SetEvaluator(netAttribute, netSource, t, esriNetworkEdgeDirection.esriNEDNone);
			}
		}
 public bool ValidateDefault(esriNetworkElementType elementType, IEvaluatedNetworkAttribute attribute, ref int errorCode, ref string errorDescription, ref string errorAppendInfo)
 {
     if (SupportsDefault(elementType, attribute))
     {
         errorCode = 0;
         errorDescription = errorAppendInfo = string.Empty;
         return true;
     }
     else
     {
         errorCode = -1;
         errorDescription = errorAppendInfo = string.Empty;
         return false;
     }
 }
		public void Initialize(INetworkDataset networkDataset, IDENetworkDataset DataElement, INetworkSource netSource, IEvaluatedNetworkAttribute netAttribute)
		{
			// Initialize is called once per session (ArcMap session, ArcCatalog session, etc.) to initialize the evaluator for an associated network dataset            
			m_networkDataset = networkDataset;
			m_networkSource = netSource;
			m_networkAttribute = netAttribute;

			Refresh();
		}
 public bool SupportsSource(INetworkSource netSource, IEvaluatedNetworkAttribute netAttribute)
 {
     // This custom evaluator supports cost attributes for all sources
     return(netAttribute.UsageType == esriNetworkAttributeUsageType.esriNAUTCost);
 }
        public void Initialize(INetworkDataset networkDataset, IDENetworkDataset DataElement, INetworkSource netSource, IEvaluatedNetworkAttribute netAttribute)
        {
            // Initialize is called once per session (ArcMap session, ArcCatalog session, etc.) to initialize the evaluator for an associated network dataset
            m_networkDataset   = networkDataset;
            m_networkSource    = netSource;
            m_networkAttribute = netAttribute;

            Refresh();
        }
		public bool SupportsSource(INetworkSource netSource, IEvaluatedNetworkAttribute netAttribute)
		{
			// This custom evaluator supports cost attributes for all sources
			return netAttribute.UsageType == esriNetworkAttributeUsageType.esriNAUTCost;
		}
		public bool SupportsDefault(esriNetworkElementType ElementType, IEvaluatedNetworkAttribute netAttribute)
		{
			return false;
		}
		public void Initialize(INetworkDataset networkDataset, IDENetworkDataset DataElement, INetworkSource netSource, IEvaluatedNetworkAttribute netAttribute)
		{
			// Initialize is called once per session (ArcMap session, ArcCatalog session, etc.) to initialize the evaluator for an associated network dataset            
			m_networkDataset = networkDataset;
			m_networkSource = netSource;
			m_networkAttribute = netAttribute;

			m_thisNetworkAttributeID = netAttribute.ID;
			m_baseNetworkAttributeID = -1;

			//The attribute name must begin with one or more non underscore characters followed by
			//an underscore character and then the name of the base cost attribute.
			//The underscore prior to the base attribute name should be the first underscore in the name.

			string thisAttributeName = netAttribute.Name;
			int nPos = thisAttributeName.IndexOf('_');
			int nLastPos = thisAttributeName.Length - 1;

			string baseNetAttributeName;
			INetworkAttribute baseNetAttribute = null;

			if (nPos > 0 && nPos < nLastPos)
			{
				baseNetAttributeName = thisAttributeName.Remove(0, nPos + 1);
				try
				{
					baseNetAttribute = networkDataset.get_AttributeByName(baseNetAttributeName);
				}
				catch (COMException ex)
				{
					baseNetAttribute = null;
					string msg = string.Format("Base Attribute ({0}) not found. {1}.", baseNetAttributeName, ex.Message);
					System.Diagnostics.Trace.WriteLine(msg, "Scale Subset Network Evaluator");
				}

				if (baseNetAttribute != null)
				{
					if (baseNetAttribute.ID != m_thisNetworkAttributeID)
						m_baseNetworkAttributeID = baseNetAttribute.ID;
				}
			}

			Refresh();
		}
        public void Initialize(INetworkDataset networkDataset, IDENetworkDataset dataElement, INetworkSource source, IEvaluatedNetworkAttribute evaluatedNetworkAttribute)
        {
            // Cache the network dataset geodatabase path
            m_workspace_path_name = ((IDataset)networkDataset).Workspace.PathName;
            m_UseSpecificDates    = false;
            m_CacheOnEverySolve   = false;
            m_RidingABicycle      = false;
            m_UsingAWheelchair    = false;
            m_networkAttribute    = evaluatedNetworkAttribute as INetworkAttribute2;

            CheckForVerboseLogging();
            if (m_VerboseLogging)
            {
                WriteToOutputFile(m_LogFile, "Initialize" + Environment.NewLine + "m_workspace_path_name: " + m_workspace_path_name + Environment.NewLine + " m_UseSpecificDates defaults to: " + m_UseSpecificDates);
            }
        }
        /// <summary>Adds new Network Attribute Evaluators</summary>
        private void AddEvaluators(NetworkAttributeInfo nai, IEvaluatedNetworkAttribute netAttr)
        {
            foreach (EvaluatorInfo eval in nai.Evaluators)
            {
                INetworkEvaluator evaluator = null;

                if (eval.EvaluatorType == eEvaluatorType.Constant)
                {
                    evaluator = new NetworkConstantEvaluatorClass();
                    if (netAttr.DataType == esriNetworkAttributeDataType.esriNADTBoolean)
                        ((INetworkConstantEvaluator)evaluator).ConstantValue = eval.Expression.Equals(bool.TrueString, StringComparison.CurrentCultureIgnoreCase);
                    else if (netAttr.DataType == esriNetworkAttributeDataType.esriNADTDouble)
                        ((INetworkConstantEvaluator)evaluator).ConstantValue = Convert.ToDouble(eval.Expression);
                    else if (netAttr.DataType == esriNetworkAttributeDataType.esriNADTFloat)
                        ((INetworkConstantEvaluator)evaluator).ConstantValue = Convert.ToSingle(eval.Expression);
                    else if (netAttr.DataType == esriNetworkAttributeDataType.esriNADTInteger)
                        ((INetworkConstantEvaluator)evaluator).ConstantValue = Convert.ToInt32(eval.Expression);
                }
                else if (eval.EvaluatorType == eEvaluatorType.Script)
                {
                    evaluator = new NetworkScriptEvaluatorClass();

#if ARCGIS_10_0     // Handle Python script language added in ArcGIS 10.1
                    if (eval.ScriptLanguage != "VBScript")
                        throw new ApplicationException(RESMGR.GetString("GPTools_OSMGPCreateNetworkDataset_invalidScriptLanguage"));

                    INetworkScriptEvaluator scriptEvaluator = (INetworkScriptEvaluator)evaluator;
                    scriptEvaluator.SetExpression(eval.Expression, eval.Prelogic);
#else
                    INetworkScriptEvaluator2 scriptEvaluator = (INetworkScriptEvaluator2)evaluator;
                    scriptEvaluator.SetLanguage(eval.ScriptLanguage);
                    scriptEvaluator.SetExpression(eval.Expression, eval.Prelogic);
#endif
                }
                else if (eval.EvaluatorType == eEvaluatorType.Field)
                {
                    evaluator = new NetworkFieldEvaluatorClass();

#if ARCGIS_10_0     // Handle Python script language added in ArcGIS 10.1
                    if (eval.ScriptLanguage != "VBScript")
                        throw new ApplicationException(RESMGR.GetString("GPTools_OSMGPCreateNetworkDataset_invalidScriptLanguage"));

                    INetworkFieldEvaluator fieldEvaluator = (INetworkFieldEvaluator)evaluator;
                    fieldEvaluator.SetExpression(eval.Expression, eval.Prelogic);
#else
                    INetworkFieldEvaluator2 fieldEvaluator = (INetworkFieldEvaluator2)evaluator;
                    fieldEvaluator.SetLanguage(eval.ScriptLanguage);
                    fieldEvaluator.SetExpression(eval.Expression, eval.Prelogic);
#endif
                }

                INetworkSource source = EnumerateNetworkSources()
                    .FirstOrDefault(ns => ns.Name.Equals(GetFullClassName(eval.Source), StringComparison.CurrentCultureIgnoreCase));
                if (source != null)
                {
                    esriNetworkEdgeDirection direction = eval.Direction;
                    if (!(source is IEdgeFeatureSource))
                        direction = esriNetworkEdgeDirection.esriNEDNone;

                    netAttr.set_Evaluator(source, direction, evaluator);
                }
            }
        }
示例#20
0
 public bool SupportsDefault(esriNetworkElementType elementType, IEvaluatedNetworkAttribute attribute)
 {
     // This custom evaluator can not be used for assigning default attribute values
     return(false);
 }
        public void Initialize(INetworkDataset networkDataset, IDENetworkDataset DataElement, INetworkSource netSource, IEvaluatedNetworkAttribute netAttribute)
        {
            // Initialize is called once per session (ArcMap session, ArcCatalog session, etc.) to initialize the evaluator for an associated network dataset
            m_networkDataset   = networkDataset;
            m_networkSource    = netSource;
            m_networkAttribute = netAttribute;

            m_thisNetworkAttributeID = netAttribute.ID;
            m_baseNetworkAttributeID = -1;

            //The attribute name must begin with one or more non underscore characters followed by
            //an underscore character and then the name of the base cost attribute.
            //The underscore prior to the base attribute name should be the first underscore in the name.

            string thisAttributeName = netAttribute.Name;
            int    nPos     = thisAttributeName.IndexOf('_');
            int    nLastPos = thisAttributeName.Length - 1;

            string            baseNetAttributeName;
            INetworkAttribute baseNetAttribute = null;

            if (nPos > 0 && nPos < nLastPos)
            {
                baseNetAttributeName = thisAttributeName.Remove(0, nPos + 1);
                try
                {
                    baseNetAttribute = networkDataset.get_AttributeByName(baseNetAttributeName);
                }
                catch (COMException ex)
                {
                    baseNetAttribute = null;
                    string msg = string.Format("Base Attribute ({0}) not found. {1}.", baseNetAttributeName, ex.Message);
                    System.Diagnostics.Trace.WriteLine(msg, "Scale Subset Network Evaluator");
                }

                if (baseNetAttribute != null)
                {
                    if (baseNetAttribute.ID != m_thisNetworkAttributeID)
                    {
                        m_baseNetworkAttributeID = baseNetAttribute.ID;
                    }
                }
            }

            Refresh();
        }
 public bool SupportsDefault(esriNetworkElementType ElementType, IEvaluatedNetworkAttribute netAttribute)
 {
     return(false);
 }
示例#23
0
        public void Initialize(INetworkDataset networkDataset, IDENetworkDataset dataElement, INetworkSource source, IEvaluatedNetworkAttribute attribute)
        {
            // Initialize is called once per session (ArcMap session, ArcCatalog session, etc.) to initialize the evaluator for an associated network dataset
            Type t = Type.GetTypeFromProgID("esriFramework.AppRef");

            try
            {
                // Activator.CreateInstance(t) is expected to error if the evaluator is created in an engine application
                // which can�t get a reference to the AppRef singleton.
                // This evaluator won�t work in Engine due to this design limitation.  It is, however,
                // fully functional in ArcMap.
                System.Object obj = Activator.CreateInstance(t);
                IApplication  app = obj as IApplication;
                if (app != null && app is IMxApplication)
                {
                    m_mxDocument = app.Document as IMxDocument;
                }
            }
            catch (Exception e)
            {
                m_mxDocument = null;
            }

            // Store reference to the network dataset and the network source
            m_networkDataset = networkDataset;
            m_networkSource  = source;

            // Create a new Dictionary hashtable for this network source
            m_sourceHashTable = new Dictionary <int, int>();
        }
示例#24
0
 public bool SupportsSource(INetworkSource source, IEvaluatedNetworkAttribute attribute)
 {
     // This custom evaluator supports restriction attributes for all sources
     return(attribute.UsageType == esriNetworkAttributeUsageType.esriNAUTRestriction);
 }
 public bool SupportsDefault(esriNetworkElementType elementType, IEvaluatedNetworkAttribute attribute)
 {
     // This custom evaluator can not be used for assigning default attribute values.
     return false;
 }
示例#26
0
 public bool ValidateSource(IDatasetContainer2 datasetContainer, INetworkSource networkSource, IEvaluatedNetworkAttribute attribute, ref int errorCode, ref string errorDescription, ref string errorAppendInfo)
 {
     if (SupportsSource(networkSource, attribute))
     {
         errorCode        = 0;
         errorDescription = errorAppendInfo = string.Empty;
         return(true);
     }
     else
     {
         errorCode        = -1;
         errorDescription = errorAppendInfo = string.Empty;
         return(false);
     }
 }
		public static void SetEvaluator(IEvaluatedNetworkAttribute netAttribute, INetworkSource netSource, Type t, esriNetworkEdgeDirection dirType)
		{
			object obj = Activator.CreateInstance(t);
			INetworkEvaluator eval = obj as INetworkEvaluator;
			netAttribute.set_Evaluator(netSource, dirType, eval);
		}
        public void Initialize(INetworkDataset networkDataset, IDENetworkDataset dataElement, INetworkSource source, IEvaluatedNetworkAttribute evaluatedNetworkAttribute)
        {
            // Cache the network dataset geodatabase path
            m_workspace_path_name = ((IDataset)networkDataset).Workspace.PathName;
            m_UseSpecificDates = false;
            m_CacheOnEverySolve = false;
            m_RidingABicycle = false;
            m_UsingAWheelchair = false;
            m_networkAttribute = evaluatedNetworkAttribute as INetworkAttribute2;

            CheckForVerboseLogging();
            if (m_VerboseLogging) WriteToOutputFile(m_LogFile, "Initialize" + Environment.NewLine + "m_workspace_path_name: " + m_workspace_path_name + Environment.NewLine + " m_UseSpecificDates defaults to: " + m_UseSpecificDates);
        }
示例#29
0
        /// <summary>Adds new Network Attribute Evaluators</summary>
        private void AddEvaluators(NetworkAttributeInfo nai, IEvaluatedNetworkAttribute netAttr)
        {
            foreach (EvaluatorInfo eval in nai.Evaluators)
            {
                INetworkEvaluator evaluator = null;

                if (eval.EvaluatorType == eEvaluatorType.Constant)
                {
                    evaluator = new NetworkConstantEvaluatorClass();
                    if (netAttr.DataType == esriNetworkAttributeDataType.esriNADTBoolean)
                    {
                        ((INetworkConstantEvaluator)evaluator).ConstantValue = eval.Expression.Equals(bool.TrueString, StringComparison.CurrentCultureIgnoreCase);
                    }
                    else if (netAttr.DataType == esriNetworkAttributeDataType.esriNADTDouble)
                    {
                        ((INetworkConstantEvaluator)evaluator).ConstantValue = Convert.ToDouble(eval.Expression);
                    }
                    else if (netAttr.DataType == esriNetworkAttributeDataType.esriNADTFloat)
                    {
                        ((INetworkConstantEvaluator)evaluator).ConstantValue = Convert.ToSingle(eval.Expression);
                    }
                    else if (netAttr.DataType == esriNetworkAttributeDataType.esriNADTInteger)
                    {
                        ((INetworkConstantEvaluator)evaluator).ConstantValue = Convert.ToInt32(eval.Expression);
                    }
                }
                else if (eval.EvaluatorType == eEvaluatorType.Script)
                {
                    evaluator = new NetworkScriptEvaluatorClass();

#if ARCGIS_10_0     // Handle Python script language added in ArcGIS 10.1
                    if (eval.ScriptLanguage != "VBScript")
                    {
                        throw new ApplicationException(RESMGR.GetString("GPTools_OSMGPCreateNetworkDataset_invalidScriptLanguage"));
                    }

                    INetworkScriptEvaluator scriptEvaluator = (INetworkScriptEvaluator)evaluator;
                    scriptEvaluator.SetExpression(eval.Expression, eval.Prelogic);
#else
                    INetworkScriptEvaluator2 scriptEvaluator = (INetworkScriptEvaluator2)evaluator;
                    scriptEvaluator.SetLanguage(eval.ScriptLanguage);
                    scriptEvaluator.SetExpression(eval.Expression, eval.Prelogic);
#endif
                }
                else if (eval.EvaluatorType == eEvaluatorType.Field)
                {
                    evaluator = new NetworkFieldEvaluatorClass();

#if ARCGIS_10_0     // Handle Python script language added in ArcGIS 10.1
                    if (eval.ScriptLanguage != "VBScript")
                    {
                        throw new ApplicationException(RESMGR.GetString("GPTools_OSMGPCreateNetworkDataset_invalidScriptLanguage"));
                    }

                    INetworkFieldEvaluator fieldEvaluator = (INetworkFieldEvaluator)evaluator;
                    fieldEvaluator.SetExpression(eval.Expression, eval.Prelogic);
#else
                    INetworkFieldEvaluator2 fieldEvaluator = (INetworkFieldEvaluator2)evaluator;
                    fieldEvaluator.SetLanguage(eval.ScriptLanguage);
                    fieldEvaluator.SetExpression(eval.Expression, eval.Prelogic);
#endif
                }

                INetworkSource source = EnumerateNetworkSources()
                                        .FirstOrDefault(ns => ns.Name.Equals(GetFullClassName(eval.Source), StringComparison.CurrentCultureIgnoreCase));
                if (source != null)
                {
                    esriNetworkEdgeDirection direction = eval.Direction;
                    if (!(source is IEdgeFeatureSource))
                    {
                        direction = esriNetworkEdgeDirection.esriNEDNone;
                    }

                    netAttr.set_Evaluator(source, direction, evaluator);
                }
            }
        }
        public bool SupportsSource(INetworkSource source, IEvaluatedNetworkAttribute attribute)
        {
            // This custom evaluator supports added costs only for edges in attributes with units of Minutes
            bool isEdgeSource = (source.ElementType == esriNetworkElementType.esriNETEdge);
            bool isCostAttribute = (attribute.UsageType == esriNetworkAttributeUsageType.esriNAUTCost);
            bool isMinutes = (attribute.Units == esriNetworkAttributeUnits.esriNAUMinutes);

            return (isEdgeSource && isCostAttribute && isMinutes);
        }
		public bool SupportsSource(INetworkSource source, IEvaluatedNetworkAttribute attribute)
		{
			// This custom evaluator supports restriction attributes for all sources
			return attribute.UsageType == esriNetworkAttributeUsageType.esriNAUTRestriction;
		}
 public bool ValidateSource(IDatasetContainer2 datasetContainer, INetworkSource networkSource, IEvaluatedNetworkAttribute attribute, ref int errorCode, ref string errorDescription, ref string errorAppendInfo)
 {
     if (SupportsSource(networkSource, attribute))
     {
         errorCode = 0;
         errorDescription = errorAppendInfo = string.Empty;
         return true;
     }
     else
     {
         errorCode = -1;
         errorDescription = errorAppendInfo = string.Empty;
         return false;
     }
 }
		public static void SetDefaultEvaluator(IEvaluatedNetworkAttribute netAttribute, object defaultValue, esriNetworkElementType eType)
		{
			INetworkConstantEvaluator constEvaluator = new NetworkConstantEvaluatorClass();
			constEvaluator.ConstantValue = defaultValue;
			INetworkEvaluator eval = constEvaluator as INetworkEvaluator;
			netAttribute.set_DefaultEvaluator(eType, eval);
		}